Skip to content
Open
Changes from all 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
28 changes: 14 additions & 14 deletions landice/mesh_tools_li/interpolate_mpasOcean_to_mali.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_data(self, year):

# open and concatenate diagnostic dataset
self.DS = xr.open_mfdataset(os.path.join(self.options.mpasoHistDir,
f'*.mpaso.hist.am.timeSeriesStatsMonthly.{year}-*-01.nc'), combine='nested', concat_dim='Time', decode_timedelta=False)
f'*.mpaso.hist.am.timeSeriesStatsMonthly.{year:04d}-*-01.nc'), combine='nested', concat_dim='Time', decode_timedelta=False)

# variables for time averaging
self.temperature = self.DS['timeMonthly_avg_activeTracers_temperature']
Expand All @@ -157,10 +157,8 @@ def get_data(self, year):
avg_layerThickness = self.DS['timeMonthly_avg_layerThickness']
self.layerThickness = avg_layerThickness.data

#xt = DS['xtime_startMonthly']

#xtime = np.array([xt],dtype=('S',64))
# << NOTE >>: may need to eventually use: "xtime.data.tobytes().decode()" but not sure yet
# monthly xtime strings (one per month), used when not time averaging
self.xtimeMonthly = self.DS['xtime_startMonthly'].values

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is xtime_startMonthly in all monthly average MPAS-O history files? I don't recognize the name, but maybe it is automatically generated by the time-averager in MPAS-O. Did you do any preprocessing of the MPAS-O history files or did your run of this script work successfully with the unmodified history files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question.

char xtime_startMonthly(Time, StrLen) ;
char xtime_endMonthly(Time, StrLen) ;

... are in all timeSeriesStatsMonthly mpas-o output files (for the Max, Min files their names are altered accordingly).

But I did NO modification of these files prior to running this script. I appears to have worked on them as is.

Note that I have spot checked the outputs from this using ncdump and they look reasonable in the sense that there are a lot of zeroes and (fewer sets of) non-zeroes for the field ismip6shelfMelt_3dThermalForcing, which look like physically reasonable ocean temperature values. But we can let this PR sit until we test them to make sure. I just don't know enough about what these fields should look like or how to check them further


self.have_landIceFreshwaterFlux = False
try:
Expand Down Expand Up @@ -227,16 +225,18 @@ def time_average_output(self):
dates.append(xt_reformat)
#self.newXtime = dates
self.newXtime = xt_reformat
else : #do nothing if not time averaging
self.newTemp = self.temperature
self.newSal = self.salinity
self.newDens= self.density
self.newLThick = self.layerThickness
self.newMpasCCE = self.mpas_cellCenterElev
self.newAtmPr = self.atmPressure
else : #keep monthly resolution, but evaluate lazy arrays to NumPy
self.newTemp = self.temperature.values
self.newSal = self.salinity.values
self.newDens = self.density.values
self.newLThick = np.asarray(self.layerThickness)
self.newMpasCCE = np.asarray(self.mpas_cellCenterElev)
self.newAtmPr = self.atmPressure.values
if self.have_landIceFreshwaterFlux:
self.newLandIceFWFlux = self.landIceFreshwaterFlux
self.newXtime = np.nan #use as placeholder for now
self.newLandIceFWFlux = self.landIceFreshwaterFlux.values
# one xtime string per month, padded to 64 characters
self.newXtime = [b.tobytes().decode().strip().ljust(64)
for b in self.xtimeMonthly]

print("New xtime: {}".format(self.newXtime))

Expand Down