# !/. # Karsten Friis # script 'transODV.sh' to transform the netCDF output of the MITgcm for an ODV input file # the output file is finally a merged data file at a certain time step # the nco commands[http://nco.sourceforge.net] have to be installed # a 12 month TS average file 'TStave_12month.nc' has to be stored somewhere # reading and merging of the chosen output variables ncks -v XC,YC,RC,Depth,HFacS grid.000001.nc ODV.nc ncks -A -v iter,o2,po4,alk,dic,dop ptracers.000001.nc ODV.nc # inventing coded (grid) station IDs like 12801, 12864, 00101, 00164 ncap -O -s "StatID[XC,YC]=(XC/2.8125+0.5)*1000+(YC/2.8125+32.5))" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a long_name,StatID,c,c,Station_gridpoint_ID ODV_is1.nc ODV_is2.nc ncap -O -s "sample_depth[RC]=abs(RC)" ODV_is2.nc ODV_is3.nc ncatted -O -a units,sample_depth,c,c,"m" ODV_is3.nc ODV.nc rm ODV_is1.nc rm ODV_is2.nc rm ODV_is3.nc # the following steps transform the units to bottle data units # this is not absolutely needed, but helps for comparisons with observations ncap -O -s "O2[o2]=(o2)*1000" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a units,O2,c,c,"umol L-1" ODV_is1.nc ODV.nc rm ODV_is1.nc ncap -O -s "PO4[po4]=(po4)*1000" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a units,PO4,c,c,"umol L-1" ODV_is1.nc ODV.nc rm ODV_is1.nc ncap -O -s "AT[alk]=(alk)*1000" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a units,AT,c,c,"umol L-1" ODV_is1.nc ODV.nc rm ODV_is1.nc ncap -O -s "CT[dic]=(dic)*1000" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a units,CT,c,c,"umol L-1" ODV_is1.nc ODV.nc rm ODV_is1.nc ncap -O -s "DOP[dop]=(dop)*1000" ODV.nc ODV_is1.nc rm ODV.nc ncatted -O -a units,DOP,c,c,"umol L-1" ODV_is1.nc ODV.nc rm ODV_is1.nc # this prints out some information about what has happend that far # and shows the 'iter' values ncks -v iter ODV.nc tmp1.nc ncdump tmp1.nc | more rm tmp1.nc # iter shows the time steps that can be cut out from the merged ODV data file # the first time step gets the Index 0 the second 1 and so on read -p "Enter the time slice You would like to get (start counting with 0,1): " SLICE read -p "Please enter the month of the time slice (01-12) you have just choosen, i.e. type in 00 for the average year:" monthID read -p "Enter the ID of this run (eg, A, B, ..) and slice (1,2,...): " runID ncks -d T,$SLICE,$SLICE ODV.nc ODV_$runID.nc # the system path is ../../../../../../../diatom/s0/kfriis/MITgcm_instructions/TS_nc/TSout_$monthID.nc # but has to be modified for other systems than mine ncks -A -v Ttave,Stave ../../../../../../../diatom/s0/kfriis/MITgcm_instructions/TS_nc/TSout_$monthID.nc ODV_$runID.nc ncks -A -v time_tsnumber monitor.000001.nc ODV_$runID.nc ncap -O -s "cruise_name[time_tsnumber]=time_tsnumber/time_tsnumber" ODV_$runID.nc ODV_is3.nc rm ODV_$runID.nc mv ODV_is3.nc ODV_$runID.nc ncks -v iter,StatID,XC,YC,Depth,HFacS,sample_depth,Ttave,Stave,O2,PO4,CT,AT,DOP,cruise_name ODV_$runID.nc ODV_is1.nc rm ODV_$runID.nc mv ODV_is1.nc ODV_$runID.nc ls