Skip to content

Commit

Permalink
Merge pull request #219 from TeaganKing/main
Browse files Browse the repository at this point in the history
[WIP] Include PRISM precipitation datm streams
  • Loading branch information
jedwards4b committed May 3, 2023
2 parents f2f773c + cd96aac commit f2c4fe1
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 8 deletions.
14 changes: 10 additions & 4 deletions cime_config/stream_cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file
# endif
# end while
index += 1
line = case.get_resolved_value(line)
lines_input_new.append(line)
#end while

Expand Down Expand Up @@ -134,14 +135,19 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file

# write contents of stream file
for stream_name in stream_names:
if stream_name.startswith("NEON."):
# include NEON.$NEONSITE non-precipitation data streams whether use PRISM or NEON precip
if stream_name.startswith("NEON.") and ('PRECIP' not in stream_name):
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : "NEON.$NEONSITE"},
err_msg="No stream_entry {} found".format(stream_name))

elif stream_name.startswith("NEON.PRISM_PRECIP"):
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : "NEON.PRISM_PRECIP.$NEONSITE"},
err_msg="No stream_entry {} found".format(stream_name))
elif stream_name.startswith("NEON.NEON_PRECIP"):
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : "NEON.NEON_PRECIP.$NEONSITE"},
err_msg="No stream_entry {} found".format(stream_name))
elif stream_name.startswith("CLM_USRDAT."):
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : "CLM_USRDAT.$CLM_USRDAT_NAME"},
err_msg="No stream_entry {} found".format(stream_name))

elif stream_name:
self.stream_nodes = super(StreamCDEPS,self).get_child("stream_entry", {"name" : stream_name},
err_msg="No stream_entry {} found".format(stream_name))
Expand Down Expand Up @@ -175,7 +181,7 @@ def create_stream_xml(self, stream_names, case, streams_xml_file, data_list_file
stream_vars[node_name] = ""
stream_datafiles = ""
for child in self.get_children(root=node):
if available_neon_data and stream_name.startswith("NEON"):
if available_neon_data and stream_name.startswith("NEON") and ('PRISM' not in stream_name):
rundir = case.get_value("RUNDIR")
for neon in available_neon_data:
stream_datafiles += os.path.join(rundir,"inputdata","atm",neon) + "\n"
Expand Down
16 changes: 13 additions & 3 deletions datm/cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ def _get_neon_data_availability(case, neonsite):
neonatm = None
dataversion = case.get_value("NEONVERSION")
if dataversion == "latest":
dataversions = ["v2", "v1"]
dataversions = ["v3", "v2", "v1"]
else:
dataversions = [dataversion]

for version in dataversions:
if not newestdate:
# Once a date range for a version has been determined for any version, the loop is complete.
# Eg, if data is available for v3, the loop will not continue to v2;
# however, if data is not available for v3, it will check for v2.
# Thus, it is important for dataversions to be listed from newest to oldest.
if not newestdate:
with open(fullpath, "r") as fd:
for line in fd.readlines():
fpath, fname = os.path.split(line)
Expand Down Expand Up @@ -106,6 +110,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
datm_presaero = case.get_value("DATM_PRESAERO")
datm_presndep = case.get_value("DATM_PRESNDEP")
datm_preso3 = case.get_value("DATM_PRESO3")
clm_usrdat_name = case.get_value("CLM_USRDAT_NAME")
datm_co2_tseries = case.get_value("DATM_CO2_TSERIES")
atm_grid = case.get_value("ATM_GRID")
model_grid = case.get_value("GRID")
Expand All @@ -129,6 +134,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
logger.debug("DATM presndep mode is {}".format(datm_presndep))
logger.debug("DATM preso3 mode is {}".format(datm_preso3))
logger.debug("DATM topo mode is {}".format(datm_topo))
logger.debug("CLM_USRDAT_NAME is {}".format(clm_usrdat_name))

# Initialize namelist defaults
config = {}
Expand All @@ -148,6 +154,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
config['datm_presaero'] = datm_presaero
config['datm_presndep'] = datm_presndep
config['datm_preso3'] = datm_preso3
config['clm_usrdat_name'] = clm_usrdat_name

if case.get_value('PTS_LON'):
scol_lon = float(case.get_value('PTS_LON'))
Expand All @@ -173,7 +180,6 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
streamlist = nmlgen.get_streams()
if type(streamlist) == type(str()):
streamlist = []

if datm_presaero != "none":
streamlist.append("presaero.{}".format(datm_presaero))
if datm_presndep != "none":
Expand All @@ -184,6 +190,10 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path
streamlist.append("topo.{}".format(datm_topo))
if datm_co2_tseries != "none":
streamlist.append("co2tseries.{}".format(datm_co2_tseries))
if clm_usrdat_name == 'NEON.PRISM':
streamlist.append(clm_usrdat_name+"_PRECIP."+neonsite)
if clm_usrdat_name == 'NEON':
streamlist.append(clm_usrdat_name+".NEON_PRECIP."+neonsite)

bias_correct = nmlgen.get_value("bias_correct")
if bias_correct is not None:
Expand Down
75 changes: 74 additions & 1 deletion datm/cime_config/stream_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@
<meshfile>none</meshfile>
</stream_meshfile>
<stream_datafiles>
<!-- v1 gets updated to newest version when using run_neon -->
<file first_year="$DATM_YR_START" last_year="$DATM_YR_END">$DIN_LOC_ROOT/atm/cdeps/v1/$NEONSITE/%ym.nc</file>
</stream_datafiles>
<stream_datavars>
<var>PRECTmms Faxa_precn</var>
<var>FSDS Faxa_swdn </var>
<var>ZBOT Sa_z </var>
<var>TBOT Sa_tbot </var>
Expand Down Expand Up @@ -267,6 +267,79 @@
<stream_readmode>single</stream_readmode>
</stream_entry>

<!-- =================================== -->
<!-- datm_mode NEON.PRISM_PRECIP.$NEONSITE -->
<!-- =================================== -->

<stream_entry name="NEON.PRISM_PRECIP.$NEONSITE">
<stream_meshfile>
<meshfile>none</meshfile>
</stream_meshfile>
<stream_datafiles>
<file first_year="$DATM_YR_START" last_year="$DATM_YR_END">$DIN_LOC_ROOT/atm/cdeps/PRISM/${NEONSITE}_%y.nc</file>
</stream_datafiles>
<stream_datavars>
<var>PRECIP Faxa_precn</var>
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>none</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>$DATM_YR_ALIGN</stream_year_align>
<stream_year_first>$DATM_YR_START</stream_year_first>
<stream_year_last>$DATM_YR_END</stream_year_last>
<stream_offset>0</stream_offset>
<stream_tintalgo>
<tintalgo>linear</tintalgo>
</stream_tintalgo>
<stream_taxmode>
<taxmode >cycle</taxmode>
<taxmode compset="HIST">limit</taxmode>
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1.5</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>

<!-- =================================== -->
<!-- datm_mode NEON.NEON_PRECIP.$NEONSITE -->
<!-- =================================== -->

<stream_entry name="NEON.NEON_PRECIP.$NEONSITE">
<stream_meshfile>
<meshfile>none</meshfile>
</stream_meshfile>
<stream_datafiles>
<!-- v1 gets updated to newest version when using run_neon -->
<file first_year="$DATM_YR_START" last_year="$DATM_YR_END">$DIN_LOC_ROOT/atm/cdeps/v1/$NEONSITE/%ym.nc</file>
</stream_datafiles>
<stream_datavars>
<var>PRECTmms Faxa_precn</var>
</stream_datavars>
<stream_lev_dimname>null</stream_lev_dimname>
<stream_mapalgo>
<mapalgo>none</mapalgo>
</stream_mapalgo>
<stream_vectors>null</stream_vectors>
<stream_year_align>$DATM_YR_ALIGN</stream_year_align>
<stream_year_first>$DATM_YR_START</stream_year_first>
<stream_year_last>$DATM_YR_END</stream_year_last>
<stream_offset>0</stream_offset>
<stream_tintalgo>
<tintalgo>linear</tintalgo>
</stream_tintalgo>
<stream_taxmode>
<taxmode >cycle</taxmode>
<taxmode compset="HIST">limit</taxmode>
</stream_taxmode>
<stream_dtlimit>
<dtlimit>1.5</dtlimit>
</stream_dtlimit>
<stream_readmode>single</stream_readmode>
</stream_entry>

<!-- =================================== -->
<!-- datm_mode CLMGSWP3v1 -->
<!-- =================================== -->
Expand Down

0 comments on commit f2c4fe1

Please sign in to comment.