Skip to content

Commit

Permalink
fix EOF500hPa issues (NOAA-GFDL#617)
Browse files Browse the repository at this point in the history
* add model/netCDF subdirectory back to PodPathManager.setupPodPaths so that existing refs are not broken in PODs
redefine date_offset variable in EOF500_hpa.compute_anomalies using the convention env var instead of the date_int_offset env_var that is no longer set

* remove debugging print statements from compute_anomalies.ncl
  • Loading branch information
wrongkindofdoctor authored Jul 12, 2024
1 parent 8c9d6ca commit 9424d6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions diagnostics/EOF_500hPa/compute_anomalies.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ wk_dir = getenv("WORK_DIR")
casename = getenv("CASENAME")
yr1 = getenv("startdate")
yr2 = getenv("enddate")
date_off = getenv("date_int_offset")
convention = getenv("convention")

; 1 for native CESM, 0 for GFDL & CMIP
if (str_match_bool_ic(convention, "CMIP") .or. str_match_bool_ic(convention, "CMIP"))
date_offset=0
else
date_offset=1
end if


use_hybrid_sigma = (getenv("USE_HYBRID_SIGMA").eq."1")

firstyr = stringtointeger(yr1)
lastyr = stringtointeger(yr2)
date_offset = stringtointeger(date_off) ; 1 for native CESM, 0 for GFDL & CMIP
;;date_offset = stringtointeger(date_off) ; 1 for native CESM, 0 for GFDL & CMIP
nyrs = lastyr-firstyr+1
nmons = nyrs*12

Expand All @@ -27,7 +36,7 @@ lev_coord = getenv("lev_coord")
file_path = getenv("DATADIR")

; Z500
if( fileexists(wk_dir+"/model/netCDF/"+casename+".Z500.ANOMS.nc") ) then
if( fileexists(wk_dir+"/model/"+casename+".Z500.ANOMS.nc") ) then

print(wk_dir+"/"+casename+".Z500.ANOMS.nc exists!!")

Expand Down Expand Up @@ -68,20 +77,24 @@ do i=0,nlat-1
end do

time_all = f_zg->$time_coord$

if (date_offset.eq.0) then
print("Using CMIP/GFDL date index YYYYMM")
; CMIP / GFDL date index, use YYYYMM
date_all = cd_calendar(time_all,-1)
year_all = date_all/100
start_date = firstyr*100+1
end_date = (lastyr)*100+12
else if (date_offset.eq.1) then
print("Using CESM date index YYYYMMDD")
; CESM native date index, use YYYYMMDD
date_all = cd_calendar(time_all,-2)
year_all = date_all/10000
start_date = firstyr*10000+201
end_date = (lastyr+1)*10000+101
end if
end if

; in either case, above only used to set following indices
do i=0,dimsizes(date_all)-1
if( date_all(i).eq.start_date ) then
Expand Down Expand Up @@ -126,14 +139,14 @@ else
z500 = f_zg->$zg_var$($time_coord$|i1:i2,$lat_coord$|:,$lon_coord$|:)
end if
; end TSJ edit

anom = (/rmMonAnnCycTLL(z500(:,:,:))/)
delete (z500)
n = 11
do yr = firstyr+1,lastyr
win_anom(yr-firstyr-1,:,:) = (/(anom(n,:,:)+anom(n+1,:,:)+anom(n+2,:,:)+anom(n+3,:,:))/4./)
n = n + 12
end do

fo = addfile(wk_dir+"/model/netCDF/"+casename+".Z500.ANOMS.nc","c")
fo->Z500_ANOM = win_anom
fo->gw = gw
Expand Down
2 changes: 1 addition & 1 deletion src/util/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def setup_pod_paths(self, pod_name: str):
filesystem.check_dir(self.POD_WORK_DIR, 'POD_WORK_DIR', create=True)
filesystem.check_dir(self.POD_OUTPUT_DIR, 'POD_OUTPUT_DIR', create=True)
# OBS data are unique to POD, so the obs output is copied to the POD subdirectory
dirs = ('model/PS', 'obs/PS', 'obs/netCDF')
dirs = ('model/PS', 'model/netCDF', 'obs/PS', 'obs/netCDF')
for d in dirs:
filesystem.check_dir(os.path.join(self.POD_WORK_DIR, d), create=True)

Expand Down

0 comments on commit 9424d6e

Please sign in to comment.