-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Preporcessing Scripts and a README to the sponges tools #96
base: main
Are you sure you want to change the base?
Changes from 5 commits
f496f90
3c23d6a
1ab6d69
0b95eec
d8812d4
c008f7f
69a42c7
e5d1d41
3d3808b
6b724d0
7a642d3
6a97df2
858a7da
04a8e08
4869c27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
## Sponges | ||
|
||
This folder contains tools for creating temperature and salinity sponges for use in MOM6 based on the GLORYS reanalysis. | ||
|
||
## preproc_scripts | ||
|
||
Scripts to subset, average, and fill the GLORYS data on the uda to preprocess it for the python scripts. | ||
|
||
# Regional Subsetting | ||
|
||
Regional subsets of the GLORYS reanalysis are created using `ncks` in `get_so_monthly.sh` and `get_thetao_monthly.sh`. | ||
You should adjust the regional subset in the script to match the region of interest. | ||
|
||
For example: | ||
``` | ||
ncks -d latitude,40.,90. -d longitude,0.,360 filein.nc fileout.nc | ||
``` | ||
|
||
# Scripts | ||
|
||
As written these preprocessing scripts must be run in three stages. | ||
1. First, subset the temperature and salinity and create monthly averages | ||
``` | ||
sbatch get_thetao_monthly.sh <YEAR> <MONTH> | ||
sbatch get_so_monthly.sh <YEAR> <MONTH> | ||
``` | ||
|
||
2. Next, fill the data | ||
``` | ||
sbatch fill_glorys_nn_monthly.sh <YEAR> <MONTH> | ||
``` | ||
|
||
3. Finally, once the filled data for every month in a given yeas have been created, the merge script can be used. | ||
``` | ||
sbatch merge_so_thetao_year.sh <YEAR> | ||
``` | ||
|
||
This should produce data that is compatible with `write_nudging_data.py` | ||
|
||
## Using these files in MOM6 | ||
|
||
To use the sponges generated by these scripts in MOM6 we reccomend the following settings: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OOPS, It's my bad but I found another one: "recommend"...... |
||
``` | ||
#override SPONGE = True | ||
#override SPONGE_UV = False | ||
#override SPONGE_DAMPING_FILE = "damping_full_t_90d.nc" | ||
#override SPONGE_IDAMP_VAR = "Idamp" | ||
#override SPONGE_STATE_FILE = "glorys_sponge_monthly_bnd_${fyear}.nc" | ||
#override SPONGE_PTEMP_VAR = "thetao" | ||
#override SPONGE_SALT_VAR = "so" | ||
#override SPONGE_ETA_VAR = "depth" | ||
#override INTERPOLATE_SPONGE_TIME_SPACE = True | ||
#override SPONGE_DATA_ONGRID = True | ||
``` | ||
These should be added to `MOM_override` in the experiment of the xml. | ||
|
||
In the xml, the paths to the files needed for sponges so that they are include in the `INPUT` directory. | ||
``` | ||
<!-- Two new files for the nudging: --> | ||
<dataFile label="input" target="INPUT/" chksum="" size="" timestamp=""> | ||
<dataSource site="ncrc">$(YOUR_PATH)/damping_full_t_90d.nc</dataSource> | ||
</dataFile> | ||
<dataFile label="input" target="INPUT/" chksum="" size="" timestamp=""> | ||
<dataSource site="ncrc">$(YOUR_PATH)/glorys_sponge_monthly_${fyear}.nc</dataSource> | ||
</dataFile> | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/tcsh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very minor, but if these are cshell scripts then maybe we should change the file extension to .csh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can change the extension, would we prefer to have them not be cshell scripts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theresa-morrison , since you're using C shell syntax (e.g., set), it might be simpler to rename the script to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch fill_glorys_nn_monthly.sh <YEAR> <MONTH> | ||
# Original Author: Andrew Ross, modified by Theresa Morrison | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
set month=`printf "%02d" $2` | ||
|
||
# Regionally-slice and convert daily to monthly GLORYS reanalysis on archive beforehand. | ||
|
||
# dmget all of the files for this month from archive. | ||
dmget /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/so/GLORYS_so_arctic_${year}_${month}.nc | ||
dmget /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/thetao/GLORYS_thetao_arctic_${year}_${month}.nc | ||
|
||
# copy from archive to vftmp for speed? | ||
#gcp /archive/acr/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/daily/GLORYS_REANALYSIS_${year}-${month}-*.nc $TMPDIR | ||
gcp /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/so/GLORYS_so_arctic_${year}_${month}.nc $TMPDIR | ||
gcp /archive/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/thetao/GLORYS_thetao_arctic_${year}_${month}.nc $TMPDIR | ||
|
||
# create a directory to store the filled files. | ||
mkdir $TMPDIR/filled | ||
|
||
# look for all of the daily files. | ||
# loop over them, using cdo setmisstonn to fill the missing data | ||
# and then ncks to compress the resulting file. | ||
find ${TMPDIR}/GLORYS_so_arctic_${year}_${month}.nc -type f -exec sh -c 'file="$1"; filename="${file##*/}"; cdo setmisstonn "$1" "${TMPDIR}/filled/${filename}"; ncks -4 -L 5 "${TMPDIR}/filled/${filename}" -O "${TMPDIR}/filled/${filename}"' find-sh {} \; | ||
find ${TMPDIR}/GLORYS_thetao_arctic_${year}_${month}.nc -type f -exec sh -c 'file="$1"; filename="${file##*/}"; cdo setmisstonn "$1" "${TMPDIR}/filled/${filename}"; ncks -4 -L 5 "${TMPDIR}/filled/${filename}" -O "${TMPDIR}/filled/${filename}"' find-sh {} \; | ||
|
||
# copy the filled data for this month to /work. | ||
gcp $TMPDIR/filled/*.nc /work/tnm/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/filled |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch fill_glorys_nn_monthly.sh <YEAR> <MONTH> | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
set month=`printf "%02d" $2` | ||
|
||
set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/so' | ||
mkdir ${apath}/so_${year}_${month} | ||
|
||
set day=1 | ||
foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/so/${year}/so_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) | ||
echo $filename | ||
set short_name='so_arctic_'$day | ||
ncks -d latitude,39.,91. --mk_rec_dmn time $filename ${apath}/so_${year}_${month}/${short_name}'_bd.nc' | ||
cdo -setreftime,1993-01-01,00:00:00,1day ${apath}/so_${year}_${month}/${short_name}'_bd.nc' ${apath}/so_${year}_${month}/${short_name}'.nc' | ||
rm -f ${apath}/so_${year}_${month}/${short_name}'_bd.nc' | ||
set day = `expr $day + 1` | ||
echo $day | ||
end | ||
ncra -O --cnk_plc=r1d --cnk_dmn=time,1 ${apath}/so_${year}_${month}/so_arctic_*.nc ${apath}/GLORYS_so_arctic_${year}_${month}.nc | ||
rm -f ${apath}/so_${year}_${month}/so_arctic_*.nc | ||
rm -rf ${apath}/so_${year}_${month} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch fill_glorys_nn_monthly.sh <YEAR> <MONTH> | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
set month=`printf "%02d" $2` | ||
|
||
set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/thetao' | ||
mkdir ${apath}/thetao_${year}_${month} | ||
|
||
set day=1 | ||
foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/thetao/${year}/thetao_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) | ||
echo $filename | ||
set short_name='thetao_arctic_'$day | ||
ncks -d latitude,39.,91. --mk_rec_dmn time $filename ${apath}/thetao_${year}_${month}/${short_name}'_bd.nc' | ||
cdo -setreftime,1993-01-01,00:00:00,1day ${apath}/thetao_${year}_${month}/${short_name}'_bd.nc' ${apath}/thetao_${year}_${month}/${short_name}'.nc' | ||
rm -f ${apath}/thetao_${year}_${month}/${short_name}'_bd.nc' | ||
set day = `expr $day + 1` | ||
echo $day | ||
end | ||
ncra -O --cnk_plc=r1d --cnk_dmn=time,1 ${apath}/thetao_${year}_${month}/thetao_arctic_*.nc ${apath}/GLORYS_thetao_arctic_${year}_${month}.nc | ||
rm -f ${apath}/thetao_${year}_${month}/thetao_arctic_*.nc | ||
rm -rf ${apath}/thetao_${year}_${month} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch fill_glorys_nn_monthly.sh <YEAR> <MONTH> | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
|
||
set wpath='/work/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/filled' | ||
|
||
# Concatenate monthly averages into single file | ||
ncrcat -O ${wpath}/GLORYS_thetao_arctic_${year}_*.nc ${wpath}/GLORYS_thetao_arctic_${year}.nc | ||
ncrcat -O ${wpath}/GLORYS_so_arctic_${year}_*.nc ${wpath}/GLORYS_so_arctic_${year}.nc | ||
|
||
# Copy salt file to name for final file | ||
cp -f ${wpath}/GLORYS_so_arctic_${year}.nc ${wpath}/GLORYS_arctic_${year}.nc | ||
|
||
# Append temperature data to renamed salinity data | ||
ncks -A ${wpath}/GLORYS_thetao_arctic_${year}.nc ${wpath}/GLORYS_arctic_${year}.nc | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to "every month in a given year has been created"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theresa-morrison, I think this PR is almost ready, except for a small comment from @uwagura that hasn’t been addressed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was waiting to see if more typos would be found before submitting a commit. I will take care of this!