From ea9d2fc098e3234577c83ea840d9fcfc682334f1 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Fri, 13 Oct 2023 12:06:44 +0100 Subject: [PATCH] add ma files. --- bgcval2/p2p/matchDataAndModel.py | 11 ++++++++++- bgcval2/timeseries/timeseriesTools.py | 16 +++++----------- key_files/ma_mld.yml | 2 +- key_files/ma_nitrate.yml | 2 +- key_files/ma_phosphate.yml | 2 +- key_files/ma_silicate.yml | 2 +- key_files/ma_sss.yml | 2 +- key_files/ma_sst.yml | 2 +- key_lists/ma_debug.yml | 6 ++++-- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/bgcval2/p2p/matchDataAndModel.py b/bgcval2/p2p/matchDataAndModel.py index 471932b2..2a9593fb 100755 --- a/bgcval2/p2p/matchDataAndModel.py +++ b/bgcval2/p2p/matchDataAndModel.py @@ -44,6 +44,7 @@ # local imports import bgcval2.bgcvaltools.bv2tools as bvt from bgcval2.bgcvaltools.pftnames import CMIP5models + ##### # These are availalble in the module: # https://gitlab.ecosystem-modelling.pml.ac.uk/ledm/netcdf_manip @@ -925,6 +926,7 @@ def loadMesh(self, modelfile=None): if self.loncc.ndim == 1 and self.loncc.shape != self.latcc.shape: self.loncc, self.latcc = np.meshgrid(self.loncc, self.latcc) + # self.depthcc = choose_best_ncvar(ncER, depthNames)[:] # if 'deptht' in list(ncER.variables.keys()): # self.depthcc = ncER.variables['deptht'][:].squeeze() @@ -934,7 +936,14 @@ def loadMesh(self, modelfile=None): # self.depthcc = ncER.variables['lev'][:].squeeze() # else: # print(self.modelcoords['z'], ncER.variables.keys()) - self.depthcc = ncER.variables[self.modelcoords['z']][:] + if self.modelcoords['z'] in ncER.variables.keys(): + self.depthcc = ncER.variables[self.modelcoords['z']][:] + else: + print('load mesh:', self.modelcoords['z'], 'is missing', ncER.variables.keys()) + if not set(ncER.variables.keys()).intersection(set(depthNames)): + print('load mesh: no depth field available in ', modelfile) + self.depthcc = np.array([0]) +# assert 0 # self.depthcc = choose_best_ncvar(ncER, depthNames)[:] self.datescc = var_to_datetime(ncER.variables[self.modelcoords['t']]) diff --git a/bgcval2/timeseries/timeseriesTools.py b/bgcval2/timeseries/timeseriesTools.py index 68dbed8d..934e8385 100644 --- a/bgcval2/timeseries/timeseriesTools.py +++ b/bgcval2/timeseries/timeseriesTools.py @@ -164,22 +164,16 @@ def getHorizontalSlice(nc, coords, details, layer, data=''): '200m', '300m', '500m', + '750m', '1000m', '2000m', '3000m', '4000m', ]: - if layer == 'Surface': z = 0. - if layer == '50m': z = 50. - if layer == '100m': z = 100. - if layer == '200m': z = 200. - if layer == '300m': z = 300. - if layer == '500m': z = 500. - if layer == '1000m': z = 1000. - if layer == '2000m': z = 2000. - if layer == '3000m': z = 3000. - if layer == '4000m': z = 4000. - print(z) + if layer == 'Surface': + z = 0. + else: + z = float(layer.replace('m', '')) k = bvt.getORCAdepth(z, nc.variables[coords['z']][:], debug=False) if isinstance(data, str): data = std_extractData(nc, details) diff --git a/key_files/ma_mld.yml b/key_files/ma_mld.yml index c63b8222..0dbacda0 100644 --- a/key_files/ma_mld.yml +++ b/key_files/ma_mld.yml @@ -11,7 +11,7 @@ model_vars : somxzint1 mldr10_1 dataFile : $BASEDIR_OBS/WOA/annual/woa18_A5B7_M0200_01.nc data_vars : M_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : layerless regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean ITCZ metrics : mean, max #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_files/ma_nitrate.yml b/key_files/ma_nitrate.yml index 5b56cf82..638fc596 100644 --- a/key_files/ma_nitrate.yml +++ b/key_files/ma_nitrate.yml @@ -12,7 +12,7 @@ model_convert : NoChange dataFile : $BASEDIR_OBS/WOA/annual/woa18_all_n00_01.nc data_vars : n_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : Surface 500m regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean metrics : mean #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_files/ma_phosphate.yml b/key_files/ma_phosphate.yml index f24ecf14..b7d578eb 100644 --- a/key_files/ma_phosphate.yml +++ b/key_files/ma_phosphate.yml @@ -12,7 +12,7 @@ model_convert : NoChange dataFile : $BASEDIR_OBS/WOA/annual/woa18_all_p00_01.nc data_vars : p_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : Surface 500m regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean metrics : mean #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_files/ma_silicate.yml b/key_files/ma_silicate.yml index b9db9b62..abf7f862 100644 --- a/key_files/ma_silicate.yml +++ b/key_files/ma_silicate.yml @@ -12,7 +12,7 @@ model_convert : NoChange dataFile : $BASEDIR_OBS/WOA/annual/woa18_all_i00_01.nc data_vars : i_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : Surface 100m 200m 500m 1000m 2000m 4000m regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean metrics : mean #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_files/ma_sss.yml b/key_files/ma_sss.yml index 8b1f1120..67b336bf 100644 --- a/key_files/ma_sss.yml +++ b/key_files/ma_sss.yml @@ -11,7 +11,7 @@ model_vars : so_abs so dataFile : /data/sthenno1/scratch/ledm/Observations/WOA/annual/woa18_decav_s00_01.nc data_vars : s_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : Surface 50m 100m 200m 500m 1000m 2000m 4000m regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean ITCZ metrics : mean #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_files/ma_sst.yml b/key_files/ma_sst.yml index 20558e9e..666527aa 100644 --- a/key_files/ma_sst.yml +++ b/key_files/ma_sst.yml @@ -12,7 +12,7 @@ model_convert : choose_best_var dataFile : /data/sthenno1/scratch/ledm/Observations/WOA/annual/woa18_decav_t00_01.nc data_vars : t_an data_convert : NoChange -data_source : WOA13 +data_source : WOA18 layers : Surface #50m 100m regions : Global NorthAtlanticOcean SouthAtlanticOcean EquatorialAtlanticOcean ITCZ metrics : mean #, median, 10pc, 20pc, 30pc, 40pc, 50pc, 60pc, 70pc, 80pc, 90pc, min, max diff --git a/key_lists/ma_debug.yml b/key_lists/ma_debug.yml index e48ec8c2..727ed8cb 100644 --- a/key_lists/ma_debug.yml +++ b/key_lists/ma_debug.yml @@ -4,5 +4,7 @@ # of how a model is working. keys: # BGC - MA_TotalIntGPP: True - MA_TotalIntNPP: True + MA_SST: True + + # MA_TotalIntGPP: True + # MA_TotalIntNPP: True