Repository navigation
Notes on CMEMS data for open boundaries
jpolton edited this page Dec 22, 2022
·
2 revisions
In this case study, we use the Atlantic - European North West Shelf - Ocean Physics Analysis and Forecast data at 1.5 km resolution for the open boundaries. Variables needed and downloadable from CMEMS AMM15 are currents, salinity, temperature and sea surface height.
Using cdo we post-process the CMEMS raw data, for example:
module load cdo
bdays=27
days=25
fileSSHqh='metoffice_foam1_amm15_NWS_SSH_b202111'$bdays'_hi202111'$days'.nc'
fileSSH='metoffice_foam1_amm15_NWS_SSH_b202111'$bdays'_dm202111'$days'.nc'
cdo timmean $fileSSHqh $fileSSH
fileTEM='metoffice_foam1_amm15_NWS_TEM_b202111'$bdays'_dm202111'$days'.nc'
fileSAL='metoffice_foam1_amm15_NWS_SAL_b202111'$bdays'_dm202111'$days'.nc'
fileOUT='CMEMS_2021_11_'$days'_download.nc'
cdo merge $fileTEM $fileSAL $fileSSH $fileOUT
fileCUR='metoffice_foam1_amm15_NWS_CUR_b202111'$bdays'_dm202111'$days'.nc'
fileOUTCUR='CMEMS_2021_11_'$days'_download_UV.nc'
cp $fileCUR $fileOUTCUR
Then using python we generate the coordinates and mask files:
module load nco/5.0.5
ncks -v lon,lat,depth,time CMEMS_2021_11_25_download.nc tmp1.nc
ncrename -d time,t -d lat,y -d lon,x tmp1.nc
ncap2 -O -s 'glamt[t,y,x]=lon' tmp1.nc tmp1.nc
ncap2 -O -s 'glamu[t,y,x]=lon' tmp1.nc tmp1.nc
ncap2 -O -s 'glamv[t,y,x]=lon' tmp1.nc tmp1.nc
ncap2 -O -s 'gphit[t,y,x]=lat' tmp1.nc tmp1.nc
ncap2 -O -s 'gphiu[t,y,x]=lat' tmp1.nc tmp1.nc
ncap2 -O -s 'gphiv[t,y,x]=lat' tmp1.nc tmp1.nc
mv tmp1.nc CMEMS_subdomain_coordinates.nc
#create masks that corresponds to the new field
ncks -v lon,lat,depth,time,so CMEMS_2021_11_25_download.nc tmp2.nc
ncks -A -v uo,vo CMEMS_2021_11_25_download_UV.nc tmp2.nc
ncatted -a _FillValue,,d,, tmp2.nc
ncap2 -O -s 'where(so>0.) so=1' tmp2.nc tmp2.nc
ncap2 -O -s 'where(so<=0.) so=0' tmp2.nc tmp2.nc
ncap2 -O -s 'where(uo>-10.) uo=1' tmp2.nc tmp2.nc
ncap2 -O -s 'where(uo<=-10.) uo=0' tmp2.nc tmp2.nc
ncap2 -O -s 'where(vo>-10.) vo=1' tmp2.nc tmp2.nc
ncap2 -O -s 'where(vo<=-10.) vo=0' tmp2.nc tmp2.nc
ncrename -d time,t -d lat,y -d lon,x tmp2.nc
ncrename -v so,tmask tmp2.nc
ncrename -v uo,umask tmp2.nc
ncrename -v vo,vmask tmp2.nc
mv tmp2.nc CMEMS_subdomain_mask.nc