-
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
Open
theresa-morrison
wants to merge
15
commits into
NOAA-GFDL:main
Choose a base branch
from
theresa-morrison:feature/add_scripts_and_readme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f496f90
Add scipts and readme for preprocessing data for sponges
3c23d6a
Merge branch 'NOAA-GFDL:main' into feature/add_scripts_and_readme
theresa-morrison 1ab6d69
Update README.md
theresa-morrison 0b95eec
Update fill_glorys_nn_monthly.sh
theresa-morrison d8812d4
Claen up scripts and add paths
c008f7f
Change file extensions
69a42c7
Remove .sh files
e5d1d41
Update paths to use TMPDIR
3d3808b
Fix Error in get_thetao
6b724d0
Simplify merge_so_thetao
7a642d3
Merge branch 'main' into feature/add_scripts_and_readme
yichengt900 6a97df2
Update README.md
theresa-morrison 858a7da
Update README.md
theresa-morrison 04a8e08
Merge branch 'main' into feature/add_scripts_and_readme
yichengt900 4869c27
Merge branch 'main' into feature/add_scripts_and_readme
yichengt900 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.csh` and `get_thetao_monthly.csh`. | ||
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.csh <YEAR> <MONTH> | ||
sbatch get_so_monthly.csh <YEAR> <MONTH> | ||
``` | ||
|
||
2. Next, fill the data | ||
``` | ||
sbatch fill_glorys_nn_monthly.csh <YEAR> <MONTH> | ||
``` | ||
|
||
3. Finally, once the filled data for every month in a given year has been created, the merge script can be used. | ||
``` | ||
sbatch merge_so_thetao_year.csh <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 recommend the following settings: | ||
``` | ||
#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, add 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> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/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> | ||
# 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` | ||
|
||
set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly' | ||
|
||
# Regionally-slice and convert daily to monthly GLORYS reanalysis on archive beforehand. | ||
|
||
# dmget all of the files for this month from archive. | ||
dmget ${apath}/so/GLORYS_so_arctic_${year}_${month}.nc ${apath}/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch get_so_monthly.csh <YEAR> <MONTH> | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
set month=`printf "%02d" $2` | ||
set var='so' | ||
set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/'${var} | ||
# create a directory to store the filled files. | ||
mkdir $TMPDIR/${var}_${year}_${month} | ||
|
||
set day=1 | ||
foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/${var}/${year}/${var}_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) | ||
echo $filename | ||
set short_name=${var}'_arctic_'$day | ||
ncks -d latitude,39.,91. --mk_rec_dmn time $filename $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' | ||
cdo -setreftime,1993-01-01,00:00:00,1day $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' $TMPDIR/${var}_${year}_${month}/${short_name}'.nc' | ||
set day = `expr $day + 1` | ||
echo $day | ||
end | ||
ncra -O $TMPDIR/${var}_${year}_${month}/${var}_arctic_*.nc ${apath}/GLORYS_${var}_arctic_${year}_${month}.nc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=fill_glorys_arctic | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch get_thetao_monthly.csh <YEAR> <MONTH> | ||
|
||
module load cdo | ||
module load nco/5.0.1 | ||
module load gcp | ||
|
||
set year=$1 | ||
set month=`printf "%02d" $2` | ||
set var='thetao' | ||
set apath='/archive/Theresa.Morrison/datasets/glorys/GLOBAL_MULTIYEAR_PHY_001_030/monthly/'${var} | ||
# create a directory to store the filled files. | ||
mkdir $TMPDIR/${var}_${year}_${month} | ||
|
||
set day=1 | ||
foreach filename (/uda/Global_Ocean_Physics_Reanalysis/global/daily/${var}/${year}/${var}_mercatorglorys12v1_gl12_mean_${year}${month}*.nc) | ||
echo $filename | ||
set short_name=${var}'_arctic_'$day | ||
ncks -d latitude,39.,91. --mk_rec_dmn time $filename $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' | ||
cdo -setreftime,1993-01-01,00:00:00,1day $TMPDIR/${var}_${year}_${month}/${short_name}'_bd.nc' $TMPDIR/${var}_${year}_${month}/${short_name}'.nc' | ||
set day = `expr $day + 1` | ||
echo $day | ||
end | ||
ncra -O $TMPDIR/${var}_${year}_${month}/${var}_arctic_*.nc ${apath}/GLORYS_${var}_arctic_${year}_${month}.nc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/tcsh | ||
#SBATCH --ntasks=1 | ||
#SBATCH --job-name=merge_so_thetao | ||
#SBATCH --time=2880 | ||
#SBATCH --partition=batch | ||
|
||
# Usage: sbatch merge_so_thetao_year.csh <YEAR> | ||
|
||
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' | ||
|
||
|
||
# Define the file variables for salinity and temperature | ||
set so_file = "${wpath}/GLORYS_so_arctic_${year}.nc" | ||
set thetao_file = "${wpath}/GLORYS_thetao_arctic_${year}.nc" | ||
set final_file = "${wpath}/GLORYS_arctic_${year}.nc" | ||
|
||
# Concatenate monthly averages into single files for salinity and temperature | ||
foreach var (so thetao) | ||
ncrcat -O ${wpath}/GLORYS_${var}_arctic_${year}_*.nc ${wpath}/GLORYS_${var}_arctic_${year}.nc | ||
end | ||
|
||
# Append temperature data to salinity file directly without copying | ||
ncks -A ${thetao_file} ${so_file} | ||
|
||
# Rename the combined file to final name | ||
mv -f ${so_file} ${final_file} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@andrew-c-ross I think this combines the dmget. Nothing is being dmget in my testing, so I'm not sure if it is working.
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.
update: not working, it is writing over my files as expected.