Skip to content
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

Replay Mover Updates #15

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 162 additions & 43 deletions examples/replay/config-0.25-degree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ FV3Dataset:
coords_path_out: "gcs://noaa-ufs-gefsv13replay/ufs-hr1/0.25-degree/coordinates/zarr/"
forecast_hours : [0, 3]

chunks_in:
# estimated 37MB per chunk (the full 3D field)
time : 1
pfull : 127
grid_yt : 768
grid_xt : 1536

chunks_out:
time : 1
pfull : 127
pfull : 1
grid_yt : 768
grid_xt : 1536

Expand All @@ -29,56 +22,182 @@ FV3Dataset:
- bk

data_vars:
# 3D atmospheric vars
- tmp
- ugrd
- vgrd
- delz
- dzdt
- dpres
- spfh
- o3mr
# 3D land vars
- soilt1
- soilt2
- soilt3
- soilt4
- acond
- albdo_ave
- alnsf
- alnwf
- alvsf
- alvwf
- c0
- cd
- cduvb_ave
- cldfra
- cnvprcp
- cnwat
- cpofp
- cprat_ave
- cpratb_ave
- crain
- csdlf
- csdsf
- csulf
- csulftoa
- csusf
- csusftoa
- cwork_aveclm
- dconv
- dlwrf
- dlwrf_ave
- dswrf
- dswrf_ave
- dswrf_avetoa
- dtcool
- duvb_ave
- ecan_acc
- edir_acc
- etran_acc
- evbs_ave
- evcw_ave
- f10m
- facsf
- facwf
- ffhh
- ffmm
- fldcp
- fricv
- frozr
- frozrb
- frzr
- frzrb
- gflux
- gflux_ave
- hgt_hyblev1
- hpbl
- icec
- icetk
- land
- lfrac
- lhtfl
- lhtfl_ave
- nbdsf_ave
- nddsf_ave
- orog
- pah_ave
- pahi
- pevpr
- pevpr_ave
- prate_ave
- prateb_ave
- pres_avehcb
- pres_avehct
- pres_avelcb
- pres_avelct
- pres_avemcb
- pres_avemct
- prescnvclb
- prescnvclt
- pressfc
- pwat
- qrain
- rhonewsn
- sbsno_ave
- sfcr
- sfexc
- shdmax
- shdmin
- shtfl
- shtfl_ave
- sltyp
- snoalb
- snod
- snohf
- snowc_ave
- soill1
- soill2
- soill3
- soill4
- soilm
- soilt1
- soilt2
- soilt3
- soilt4
- soilw1
- soilw2
- soilw3
- soilw4
# 2D vars
- snod
- prateb_ave
- pressfc
- weasd
- f10m
- sfcr
# Surface forcing vars
- land
- vtype
- sotyp
- veg
- icec
- spfh2m
- spfh_hyblev1
- spfhmax_max2m
- spfhmin_min2m
- ssrun_acc
- sunsd_acc
- tcdc_avebndcl
- tcdc_aveclm
- tcdc_avehcl
- tcdc_avelcl
- tcdc_avemcl
- tcdccnvcl
- tg3
- tisfc
- tmax_max2m
- tmin_min2m
- tmp2m
- tmp_avehct
- tmp_avelct
- tmp_avemct
- tmp_hyblev1
- tmpsfc
# For TOA solar radiation
- dswrf_avetoa
- tprcp
- trans_ave
- tref
- tsnowp
- tsnowpb
- u-gwd_ave
- uflx_ave
- ugrd10m
- ugrd_hyblev1
- ulwrf
- ulwrf_ave
- ulwrf_avetoa
- uswrf
- uswrf_ave
- uswrf_avetoa
# Ease comparison
- tmp2m
- ugrd10m
- v-gwd_ave
- vbdsf_ave
- vddsf_ave
- veg
- vflx_ave
- vgrd10m
# For cloudy assimilation
- vgrd_hyblev1
- vtype
- w0
- wa_acc
- watr_acc
- wd
- weasd
- wilt
- xs
- xt
- xtts
- xu
- xv
- xz
- xzts
- zc
- clwmr
- delz
- dpres
- dzdt
- grle
- hgtsfc
- icmr
- nicp
- ntrnc
- o3mr
- rwmr
- snmr
# For future operational implementation
- ntrnc
- nicp
- spfh
- tmp
- ugrd
- vgrd
4 changes: 1 addition & 3 deletions examples/replay/fill_quarter_degree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def submit_slurm_filler(job_id, mover):
f"from replay_filler import ReplayFiller\n"+\
f"mover = ReplayMoverQuarterDegree(\n"+\
f" n_jobs={mover.n_jobs},\n"+\
f" n_cycles={mover.n_cycles},\n"+\
f" config_filename='{mover.config_filename}',\n"+\
f" storage_options={mover.storage_options},\n"+\
f" main_cache_path='{mover.main_cache_path}',\n"+\
Expand Down Expand Up @@ -56,8 +55,7 @@ def submit_slurm_filler(job_id, mover):

# Recreated from what we used to put up quarter degree in the first place
mover = ReplayMoverQuarterDegree(
n_jobs=15
n_cycles=1,
n_jobs=1,
config_filename="config-0.25-degree.yaml",
storage_options={"token": "/contrib/Tim.Smith/.gcs/replay-service-account.json"},
main_cache_path="/lustre/Tim.Smith/tmp-replay/0.25-degree",
Expand Down
11 changes: 11 additions & 0 deletions examples/replay/find_nans.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/bash

echo " --- 0.25 Degree ---"
awk '!/ 0 NaN/ && (/NaN/) {print FILENAME, $1, $2, $3, $4}' slurm/verify-0.25-degree/march15/*.out
echo ""
echo ""

echo " --- 1.00 Degree ---"
awk '!/ 0 NaN/ && (/NaN/) {print FILENAME, $1, $2, $3, $4}' slurm/verify-1.00-degree/*.out
echo ""
echo ""
24 changes: 14 additions & 10 deletions examples/replay/replay_mover.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep these were the exact same bugs I found!

  • import logging was needed
  • in def(run) when you called move_single_dataset it would say replay doesn't exist so had to be fixed.

I did not make the updates to region on my end, but I see why that was needed. I think one time I got an error that "pfull" didnt exist because none of the variables in that specific run had that dimension so I think I just commented out pfull and it worked fine. But anyways -- this is an actual fix!

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os.path import join, isdir
from datetime import datetime, timedelta
import logging
import yaml
from shutil import rmtree
import itertools
Expand Down Expand Up @@ -136,15 +137,14 @@ def run(self, job_id):

walltime = Timer()
localtime = Timer()
replay = FV3Dataset(path_in=self.cached_path, config_filename=self.config_filename)

store_coords = False # we don't need a separate coords dataset for FV3
for cycle in self.my_cycles(job_id):

localtime.start(f"Reading {str(cycle)}")

try:
self.move_single_dataset(cycle)
self.move_single_dataset(job_id, cycle)
except Exception as e:
logging.exception(e)
print(f"ReplayMover.run({job_id}): Failed to store {str(cycle)}")
Expand All @@ -153,22 +153,26 @@ def run(self, job_id):

walltime.stop("Total Walltime")

def move_single_dataset(self, cycle):
def move_single_dataset(self, job_id, cycle):
"""Store a single cycle to zarr"""

replay = FV3Dataset(path_in=self.cached_path, config_filename=self.config_filename)
xds = replay.open_dataset(cycle, **self.ods_kwargs(job_id))

index = list(self.xtime.values).index(xds.time.values[0])
tslice = slice(index, index+2)

region = {
"time": tslice,
"pfull": slice(None, None),
"grid_yt": slice(None, None),
"grid_xt": slice(None, None),
}
region = {k : v for k,v in region.items() if k in xds.dims}

replay.store_dataset(
xds,
region={
"time": tslice,
"pfull": slice(None, None),
"grid_yt": slice(None, None),
"grid_xt": slice(None, None),
},
region=region,
storage_options=self.storage_options,
)
# This is a hacky way to clear the cache, since we don't create a filesystem object
Expand Down Expand Up @@ -226,7 +230,7 @@ def store_container(self):

localtime.start("Storing to zarr")
store = NestedDirectoryStore(path=replay.data_path) if replay.is_nested else replay.data_path
dds.to_zarr(store, compute=False, storage_options=self.storage_options)
dds.to_zarr(store, compute=False, storage_options=self.storage_options, mode="w")
localtime.stop()

# This is a hacky way to clear the cache, since we don't create a filesystem object
Expand Down
14 changes: 14 additions & 0 deletions examples/replay/submit_move_quarter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

#SBATCH -J quarter_container
#SBATCH -o slurm/quarter_container.%j.out
#SBATCH -e slurm/quarter_container.%j.err
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=30
#SBATCH --partition=compute
#SBATCH -t 120:00:00

source /contrib/Tim.Smith/miniconda3/etc/profile.d/conda.sh
conda activate ufs2arco
python move_quarter_degree.py
Loading
Loading