| 1 |
edhill |
1.1 |
# !/. |
| 2 |
|
|
# Karsten Friis |
| 3 |
|
|
# script 'transODV.sh' to transform the netCDF output of the MITgcm for an ODV input file |
| 4 |
|
|
# the output file is finally a merged data file at a certain time step |
| 5 |
|
|
# the nco commands[http://nco.sourceforge.net] have to be installed |
| 6 |
|
|
# a 12 month TS average file 'TStave_12month.nc' has to be stored somewhere |
| 7 |
|
|
|
| 8 |
|
|
# reading and merging of the chosen output variables |
| 9 |
|
|
ncks -v XC,YC,RC,Depth,HFacS grid.000001.nc ODV.nc |
| 10 |
|
|
ncks -A -v iter,o2,po4,alk,dic,dop ptracers.000001.nc ODV.nc |
| 11 |
|
|
|
| 12 |
|
|
# inventing coded (grid) station IDs like 12801, 12864, 00101, 00164 |
| 13 |
|
|
ncap -O -s "StatID[XC,YC]=(XC/2.8125+0.5)*1000+(YC/2.8125+32.5))" ODV.nc ODV_is1.nc |
| 14 |
|
|
rm ODV.nc |
| 15 |
|
|
ncatted -O -a long_name,StatID,c,c,Station_gridpoint_ID ODV_is1.nc ODV_is2.nc |
| 16 |
|
|
ncap -O -s "sample_depth[RC]=abs(RC)" ODV_is2.nc ODV_is3.nc |
| 17 |
|
|
ncatted -O -a units,sample_depth,c,c,"m" ODV_is3.nc ODV.nc |
| 18 |
|
|
rm ODV_is1.nc |
| 19 |
|
|
rm ODV_is2.nc |
| 20 |
|
|
rm ODV_is3.nc |
| 21 |
|
|
|
| 22 |
|
|
# the following steps transform the units to bottle data units |
| 23 |
|
|
# this is not absolutely needed, but helps for comparisons with observations |
| 24 |
|
|
|
| 25 |
|
|
ncap -O -s "O2[o2]=(o2)*1000" ODV.nc ODV_is1.nc |
| 26 |
|
|
rm ODV.nc |
| 27 |
|
|
ncatted -O -a units,O2,c,c,"umol L-1" ODV_is1.nc ODV.nc |
| 28 |
|
|
rm ODV_is1.nc |
| 29 |
|
|
|
| 30 |
|
|
ncap -O -s "PO4[po4]=(po4)*1000" ODV.nc ODV_is1.nc |
| 31 |
|
|
rm ODV.nc |
| 32 |
|
|
ncatted -O -a units,PO4,c,c,"umol L-1" ODV_is1.nc ODV.nc |
| 33 |
|
|
rm ODV_is1.nc |
| 34 |
|
|
|
| 35 |
|
|
ncap -O -s "AT[alk]=(alk)*1000" ODV.nc ODV_is1.nc |
| 36 |
|
|
rm ODV.nc |
| 37 |
|
|
ncatted -O -a units,AT,c,c,"umol L-1" ODV_is1.nc ODV.nc |
| 38 |
|
|
rm ODV_is1.nc |
| 39 |
|
|
|
| 40 |
|
|
ncap -O -s "CT[dic]=(dic)*1000" ODV.nc ODV_is1.nc |
| 41 |
|
|
rm ODV.nc |
| 42 |
|
|
ncatted -O -a units,CT,c,c,"umol L-1" ODV_is1.nc ODV.nc |
| 43 |
|
|
rm ODV_is1.nc |
| 44 |
|
|
|
| 45 |
|
|
ncap -O -s "DOP[dop]=(dop)*1000" ODV.nc ODV_is1.nc |
| 46 |
|
|
rm ODV.nc |
| 47 |
|
|
ncatted -O -a units,DOP,c,c,"umol L-1" ODV_is1.nc ODV.nc |
| 48 |
|
|
rm ODV_is1.nc |
| 49 |
|
|
|
| 50 |
|
|
# this prints out some information about what has happend that far |
| 51 |
|
|
# and shows the 'iter' values |
| 52 |
|
|
ncks -v iter ODV.nc tmp1.nc |
| 53 |
|
|
ncdump tmp1.nc | more |
| 54 |
|
|
rm tmp1.nc |
| 55 |
|
|
|
| 56 |
|
|
# iter shows the time steps that can be cut out from the merged ODV data file |
| 57 |
|
|
# the first time step gets the Index 0 the second 1 and so on |
| 58 |
|
|
read -p "Enter the time slice You would like to get (start counting with 0,1): " SLICE |
| 59 |
|
|
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 |
| 60 |
|
|
read -p "Enter the ID of this run (eg, A, B, ..) and slice (1,2,...): " runID |
| 61 |
|
|
ncks -d T,$SLICE,$SLICE ODV.nc ODV_$runID.nc |
| 62 |
|
|
|
| 63 |
|
|
# the system path is ../../../../../../../diatom/s0/kfriis/MITgcm_instructions/TS_nc/TSout_$monthID.nc |
| 64 |
|
|
# but has to be modified for other systems than mine |
| 65 |
|
|
ncks -A -v Ttave,Stave ../../../../../../../diatom/s0/kfriis/MITgcm_instructions/TS_nc/TSout_$monthID.nc ODV_$runID.nc |
| 66 |
|
|
ncks -A -v time_tsnumber monitor.000001.nc ODV_$runID.nc |
| 67 |
|
|
ncap -O -s "cruise_name[time_tsnumber]=time_tsnumber/time_tsnumber" ODV_$runID.nc ODV_is3.nc |
| 68 |
|
|
rm ODV_$runID.nc |
| 69 |
|
|
mv ODV_is3.nc ODV_$runID.nc |
| 70 |
|
|
|
| 71 |
|
|
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 |
| 72 |
|
|
rm ODV_$runID.nc |
| 73 |
|
|
mv ODV_is1.nc ODV_$runID.nc |
| 74 |
|
|
|
| 75 |
|
|
ls |