diff --git a/marisco/_modidx.py b/marisco/_modidx.py index 8e5c882..211ad40 100644 --- a/marisco/_modidx.py +++ b/marisco/_modidx.py @@ -279,6 +279,43 @@ 'marisco/nc_template.py'), 'marisco.nc_template.NCTemplater.nuclide_vars': ( 'api/nc_template.html#nctemplater.nuclide_vars', 'marisco/nc_template.py')}, + 'marisco.netcdf_to_csv': { 'marisco.netcdf_to_csv.LookupNuclideIdCB': ( 'handlers/netcdf_to_csv.html#lookupnuclideidcb', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.LookupNuclideIdCB.__call__': ( 'handlers/netcdf_to_csv.html#__call__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.LookupNuclideIdCB.__init__': ( 'handlers/netcdf_to_csv.html#__init__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.LookupSampleType': ( 'handlers/netcdf_to_csv.html#lookupsampletype', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.LookupSampleType.__call__': ( 'handlers/netcdf_to_csv.html#__call__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.LookupSampleType.__init__': ( 'handlers/netcdf_to_csv.html#__init__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.ParseTimeCB': ( 'handlers/netcdf_to_csv.html#parsetimecb', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.ParseTimeCB.__call__': ( 'handlers/netcdf_to_csv.html#__call__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.ParseTimeCB.__init__': ( 'handlers/netcdf_to_csv.html#__init__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.ParseTimeCB.format_time': ( 'handlers/netcdf_to_csv.html#format_time', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.RenameColumnCB': ( 'handlers/netcdf_to_csv.html#renamecolumncb', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.RenameColumnCB.__call__': ( 'handlers/netcdf_to_csv.html#__call__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.RenameColumnCB.__init__': ( 'handlers/netcdf_to_csv.html#__init__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.TransposeNuclideColumns': ( 'handlers/netcdf_to_csv.html#transposenuclidecolumns', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.TransposeNuclideColumns.__call__': ( 'handlers/netcdf_to_csv.html#__call__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.TransposeNuclideColumns.__init__': ( 'handlers/netcdf_to_csv.html#__init__', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.TransposeNuclideColumns.transpose_nuclides': ( 'handlers/netcdf_to_csv.html#transpose_nuclides', + 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.encode': ('handlers/netcdf_to_csv.html#encode', 'marisco/netcdf_to_csv.py'), + 'marisco.netcdf_to_csv.get_nucnames_lut': ( 'handlers/netcdf_to_csv.html#get_nucnames_lut', + 'marisco/netcdf_to_csv.py')}, 'marisco.serializers': { 'marisco.serializers.NetCDFEncoder': ('api/serializers.html#netcdfencoder', 'marisco/serializers.py'), 'marisco.serializers.NetCDFEncoder.__init__': ( 'api/serializers.html#__init__', 'marisco/serializers.py'), diff --git a/marisco/configs.py b/marisco/configs.py index 3fc72bd..02544b4 100644 --- a/marisco/configs.py +++ b/marisco/configs.py @@ -240,7 +240,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) }, 'suffixes': { 'uncertainty': { - 'name': 'unc', + 'name': '_unc', 'attrs': { 'long_name': ' uncertainty', 'standard_name': '_uncertainty' @@ -248,7 +248,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'f4' }, 'detection_limit': { - 'name': 'dl', + 'name': '_dl', 'attrs': { 'long_name': ' detection limit', 'standard_name': '_detection_limit' @@ -256,7 +256,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'dl_t' }, 'volume': { - 'name': 'vol', + 'name': '_vol', 'attrs': { 'long_name': ' volume', 'standard_name': '_volume' @@ -264,7 +264,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'f4' }, 'salinity': { - 'name': 'sal', + 'name': '_sal', 'attrs': { 'long_name': ' salinity', 'standard_name': '_sal' @@ -272,7 +272,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'f4' }, 'temperature': { - 'name': 'temp', + 'name': '_temp', 'attrs': { 'long_name': ' temperature', 'standard_name': '_temp' @@ -280,7 +280,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'f4' }, 'filtered': { - 'name': 'filt', + 'name': '_filt', 'attrs': { 'long_name': ' filtered', 'standard_name': '_filtered' @@ -288,7 +288,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'filt_t' }, 'counting_method': { - 'name': 'counmet', + 'name': '_counmet', 'attrs': { 'long_name': ' counting method', 'standard_name': '_counting_method' @@ -296,7 +296,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'counmet_t' }, 'sampling_method': { - 'name': 'sampmet', + 'name': '_sampmet', 'attrs': { 'long_name': ' sampling method', 'standard_name': '_sampling_method' @@ -304,7 +304,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'sampmet_t' }, 'preparation_method': { - 'name': 'prepmet', + 'name': '_prepmet', 'attrs': { 'long_name': ' preparation method', 'standard_name': '_preparation_method' @@ -312,7 +312,7 @@ def cache_path(): return Path(cfg()['dirs']['cache']) 'dtype': 'prepmet_t' }, 'unit': { - 'name': 'unit', + 'name': '_unit', 'attrs': { 'long_name': ' unit', 'standard_name': '_unit' diff --git a/marisco/nc_template.py b/marisco/nc_template.py index 2f4d47b..cf6ac33 100644 --- a/marisco/nc_template.py +++ b/marisco/nc_template.py @@ -73,7 +73,8 @@ def derive( ) -> dict: # Derived variable name and associated attributes "Derive NetCDF nuclide-dependent variable names & attributes as defined in CDL." return { - 'name': nuclide['name'] + '_' + suffix['name'], + # 'name': nuclide['name'] + '_' + suffix['name'], + 'name': nuclide['name'] + suffix['name'], 'dtype': suffix['dtype'], # Using dtype from suffix 'attrs': {key: nuclide['attrs'][key] + suffix['attrs'][key] for key in nuclide['attrs']} } diff --git a/marisco/netcdf_to_csv.py b/marisco/netcdf_to_csv.py new file mode 100644 index 0000000..2b1138e --- /dev/null +++ b/marisco/netcdf_to_csv.py @@ -0,0 +1,152 @@ +# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/handlers/netcdf_to_csv.ipynb. + +# %% auto 0 +__all__ = ['sample_cols_grp', 'sample_type_lut', 'coi_grp', 'renaming_rules', 'TransposeNuclideColumns', 'ParseTimeCB', + 'LookupSampleType', 'get_nucnames_lut', 'LookupNuclideIdCB', 'RenameColumnCB', 'encode'] + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 15 +# Define cols that are not nuclides +sample_cols_grp = {'seawater': ['sample','lon', 'lat', 'depth', 'time'], + 'sediment': ['sample', 'lon', 'lat', 'depth', 'time', 'sed_type'], + 'biota': ['sample', 'lon', 'lat', 'depth', 'time', 'species_id', 'body_part']} + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 16 +class TransposeNuclideColumns(Callback): + + " Transpose NetCDF nuclide data." + def __init__(self, cols_grp=sample_cols_grp): fc.store_attr() + + def __call__(self, tfm): + for grp in tfm.dfs.keys(): + tfm.dfs[grp]=self.transpose_nuclides(tfm.dfs[grp], grp) + + def transpose_nuclides(self, df, group): + sample_cols=self.cols_grp[group] + nuclide_unc_unit_cols=list(set(df.columns) - set(sample_cols)) + unc_cols=[x for x in nuclide_unc_unit_cols if '_unc' in x] + unit_cols=[x for x in nuclide_unc_unit_cols if '_unit' in x] + dl_cols=[x for x in nuclide_unc_unit_cols if '_dl' in x] + nuclide_cols= list(set(nuclide_unc_unit_cols) - set(unit_cols+unc_cols+dl_cols)) + + # Transpose nuclide_cols + nuclide_df=pd.melt(frame=df, id_vars=sample_cols, value_vars=nuclide_cols, var_name='nuclide', value_name='activity') + + # Transpose unc_cols + unc_df=pd.melt(frame=df, id_vars=sample_cols, value_vars=unc_cols, var_name='nuclide', value_name='uncertainty') + unc_df['nuclide'] = unc_df['nuclide'].str.replace('_unc', '') + + # Transpose unit_cols + unit_df=pd.melt(frame=df, id_vars=sample_cols, value_vars=unit_cols, var_name='nuclide', value_name='unit_id') + unit_df['nuclide'] = unit_df['nuclide'].str.replace('_unit', '') + + # Transpose dl_cols + dl_df=pd.melt(frame=df, id_vars=sample_cols, value_vars=dl_cols, var_name='nuclide', value_name='dl') + dl_df['nuclide'] = dl_df['nuclide'].str.replace('_dl', '') + + # Combine nuclide_df, unc_df, unit_df and dl_df + combine_on=sample_cols+['nuclide'] + df = pd.merge(nuclide_df, unc_df, how='outer', left_on= combine_on, right_on = combine_on) + df = pd.merge(df, unit_df, how='outer', left_on= combine_on, right_on = combine_on) + df = pd.merge(df, dl_df, how='outer', left_on= combine_on, right_on = combine_on) + + # Keep all rows where 'activity' is not 'nan' OR 'uncertainty' is not 'nan' OR 'dl' is not 'nan' OR'unit_id' not equal 0. + df=df[(df['activity'].notna()) | (df['uncertainty'].notna()) | (df['dl'].notna()) | (df['unit_id'] != 0 )] + return(df) + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 20 +class ParseTimeCB(Callback): + def __init__(self, cfg): fc.store_attr() + def __call__(self, tfm): + for k in tfm.dfs.keys(): + tfm.dfs[k]['time'] = tfm.dfs[k]['time'].apply(self.format_time) + def format_time(self, x): + return num2pydate(x, units=self.cfg['units']['time']) + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 24 +# Define sample types groups +sample_type_lut = {'seawater': 1, + 'sediment': 2, + 'biota': 3, + 'suspended matter': 4} + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 25 +class LookupSampleType(Callback): + def __init__(self, lut=sample_type_lut): fc.store_attr() + def __call__(self, tfm): + for k in tfm.dfs.keys(): + tfm.dfs[k]['samptype_id'] = self.lut[k] + + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 29 +def get_nucnames_lut(): + fname = lut_path() / 'dbo_nuclide.xlsx' + df_nuclide = pd.read_excel(fname, usecols=['nuclide_id', 'nc_name']) + return df_nuclide.set_index('nc_name').to_dict()['nuclide_id'] + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 30 +class LookupNuclideIdCB(Callback): + "Lookup MARIS nuclide_id." + def __init__(self, + fn_lut=get_nucnames_lut): + fc.store_attr() + + def __call__(self, tfm): + lut = self.fn_lut() + for k in tfm.dfs.keys(): + tfm.dfs[k]['nuclide_id'] = tfm.dfs[k]['nuclide'].replace(lut) + tfm.dfs[k]['nuclide_id']=tfm.dfs[k]['nuclide_id'].astype('int64') + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 39 +# Define columns of interest by sample type +coi_grp = {'seawater': ['sample', 'lon', 'lat', 'depth', 'time', 'nuclide', 'activity', + 'uncertainty', 'unit_id', 'dl', 'samptype_id', 'nuclide_id'], + 'sediment' : ['sample', 'lon', 'lat', 'depth', 'time', 'sed_type', 'nuclide', + 'activity', 'uncertainty', 'unit_id', 'dl', 'samptype_id', 'nuclide_id'], + 'biota' : ['sample', 'lon', 'lat', 'depth', 'time', 'species_id', 'body_part', + 'nuclide', 'activity', 'uncertainty', 'unit_id', 'dl', 'samptype_id', 'nuclide_id']} + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 40 +# Define column names renaming rules +renaming_rules = { + 'lat': 'latitude', + 'lon': 'longitude', + 'time': 'begperiod', + 'depth': 'sampdepth', + 'nuclide': 'nuclide_id', + 'uncertainty': 'uncertaint', + 'dl': 'detection', + 'sed_type': 'sedtype_id (0)', + 'species_id': 'species_id (0)', + 'body_part': 'bodypar_id', +} + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 41 +class RenameColumnCB(Callback): + def __init__(self, + coi=coi_grp, + renaming_rules=renaming_rules): + fc.store_attr() + + def __call__(self, tfm): + for k in tfm.dfs.keys(): + # Select cols of interest + tfm.dfs[k] = tfm.dfs[k].loc[:, self.coi[k]] + + # Rename cols + tfm.dfs[k].rename(columns=self.renaming_rules, inplace=True) + +# %% ../nbs/handlers/netcdf_to_csv.ipynb 45 +def encode(fname_in, fname_out, **kwargs): + dfs = netcdf4_to_df(fname_in) + tfm = Transformer(dfs, cbs=[TransposeNuclideColumns(), + ParseTimeCB(cfg()), + LookupSampleType(), + LookupNuclideIdCB(), + RenameColumnCB() + ]) + + encoder = OpenRefineCsvEncoder(tfm(), + dest_fname=fname_out, + **kwargs) + encoder.encode() + return encoder diff --git a/nbs/api/configs.ipynb b/nbs/api/configs.ipynb index a4dab45..ecfc818 100644 --- a/nbs/api/configs.ipynb +++ b/nbs/api/configs.ipynb @@ -399,7 +399,7 @@ " },\n", " 'suffixes': {\n", " 'uncertainty': {\n", - " 'name': 'unc',\n", + " 'name': '_unc',\n", " 'attrs': {\n", " 'long_name': ' uncertainty',\n", " 'standard_name': '_uncertainty'\n", @@ -407,7 +407,7 @@ " 'dtype': 'f4'\n", " },\n", " 'detection_limit': {\n", - " 'name': 'dl',\n", + " 'name': '_dl',\n", " 'attrs': {\n", " 'long_name': ' detection limit',\n", " 'standard_name': '_detection_limit'\n", @@ -415,7 +415,7 @@ " 'dtype': 'dl_t'\n", " },\n", " 'volume': {\n", - " 'name': 'vol',\n", + " 'name': '_vol',\n", " 'attrs': {\n", " 'long_name': ' volume',\n", " 'standard_name': '_volume'\n", @@ -423,7 +423,7 @@ " 'dtype': 'f4'\n", " },\n", " 'salinity': {\n", - " 'name': 'sal',\n", + " 'name': '_sal',\n", " 'attrs': {\n", " 'long_name': ' salinity',\n", " 'standard_name': '_sal'\n", @@ -431,7 +431,7 @@ " 'dtype': 'f4'\n", " },\n", " 'temperature': {\n", - " 'name': 'temp',\n", + " 'name': '_temp',\n", " 'attrs': {\n", " 'long_name': ' temperature',\n", " 'standard_name': '_temp'\n", @@ -439,7 +439,7 @@ " 'dtype': 'f4'\n", " },\n", " 'filtered': {\n", - " 'name': 'filt',\n", + " 'name': '_filt',\n", " 'attrs': {\n", " 'long_name': ' filtered',\n", " 'standard_name': '_filtered'\n", @@ -447,7 +447,7 @@ " 'dtype': 'filt_t'\n", " },\n", " 'counting_method': {\n", - " 'name': 'counmet',\n", + " 'name': '_counmet',\n", " 'attrs': {\n", " 'long_name': ' counting method',\n", " 'standard_name': '_counting_method'\n", @@ -455,7 +455,7 @@ " 'dtype': 'counmet_t'\n", " },\n", " 'sampling_method': {\n", - " 'name': 'sampmet',\n", + " 'name': '_sampmet',\n", " 'attrs': {\n", " 'long_name': ' sampling method',\n", " 'standard_name': '_sampling_method'\n", @@ -463,7 +463,7 @@ " 'dtype': 'sampmet_t'\n", " },\n", " 'preparation_method': {\n", - " 'name': 'prepmet',\n", + " 'name': '_prepmet',\n", " 'attrs': {\n", " 'long_name': ' preparation method',\n", " 'standard_name': '_preparation_method'\n", @@ -471,7 +471,7 @@ " 'dtype': 'prepmet_t'\n", " },\n", " 'unit': {\n", - " 'name': 'unit',\n", + " 'name': '_unit',\n", " 'attrs': {\n", " 'long_name': ' unit',\n", " 'standard_name': '_unit'\n", @@ -998,15 +998,28 @@ "metadata": {}, "outputs": [ { - "ename": "AttributeError", - "evalue": "'dict' object has no attribute 'types'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn [74], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43menums\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtypes\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124munit_t\u001b[39m\u001b[38;5;124m'\u001b[39m]\n", - "\u001b[0;31mAttributeError\u001b[0m: 'dict' object has no attribute 'types'" - ] + "data": { + "text/plain": [ + "{'Not applicable': -1,\n", + " 'NOT AVAILABLE': 0,\n", + " 'Bq per m3': 1,\n", + " 'Bq per m2': 2,\n", + " 'Bq per kg': 3,\n", + " 'Bq per kgd': 4,\n", + " 'Bq per kgw': 5,\n", + " 'kg per kg': 6,\n", + " 'TU': 7,\n", + " 'DELTA per mill': 8,\n", + " 'atom per kg': 9,\n", + " 'atom per kgd': 10,\n", + " 'atom per kgw': 11,\n", + " 'atom per l': 12,\n", + " 'Bq per kgC': 13}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -3495,14 +3508,6 @@ "source": [ "enums['species_t']" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8ca73383", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/nbs/api/nc_template.ipynb b/nbs/api/nc_template.ipynb index a515f75..befbf53 100644 --- a/nbs/api/nc_template.ipynb +++ b/nbs/api/nc_template.ipynb @@ -1842,7 +1842,8 @@ ") -> dict: # Derived variable name and associated attributes\n", " \"Derive NetCDF nuclide-dependent variable names & attributes as defined in CDL.\" \n", " return {\n", - " 'name': nuclide['name'] + '_' + suffix['name'],\n", + " # 'name': nuclide['name'] + '_' + suffix['name'],\n", + " 'name': nuclide['name'] + suffix['name'],\n", " 'dtype': suffix['dtype'], # Using dtype from suffix\n", " 'attrs': {key: nuclide['attrs'][key] + suffix['attrs'][key] for key in nuclide['attrs']}\n", " }" @@ -1909,7 +1910,7 @@ "source": [ "# Example of suffix defined in the .cdl file\n", "suffix = {\n", - " 'name': 'unc',\n", + " 'name': '_unc',\n", " 'attrs': {\n", " 'long_name': ' uncertainty',\n", " 'standard_name': '_uncertainty'\n", @@ -2057,75 +2058,33 @@ " nc_var.setncatts(attrs) " ] }, - { - "cell_type": "markdown", - "id": "23fef7dd", - "metadata": {}, - "source": [ - "## Troubleshooting na values" - ] - }, { "cell_type": "code", "execution_count": null, "id": "cf1e93a3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "enum unit(sample)\n", - " _FillValue: -1\n", - "enum data type: int64\n", - "unlimited dimensions: \n", - "current shape = (4,)\n" - ] - } - ], + "outputs": [], "source": [ - "from netCDF4 import Dataset\n", - "import numpy as np\n", + "# Troubleshooting na values\n", + "# from netCDF4 import Dataset\n", + "# import numpy as np\n", "\n", - "with Dataset(\"test.nc\", \"w\", format=\"NETCDF4\") as nc:\n", - " sample = nc.createDimension(\"sample\", 4)\n", + "# with Dataset(''./files/nc/test-na-values.nc', 'w', format='NETCDF4') as nc:\n", + "# sample = nc.createDimension(\"sample\", 4)\n", "\n", - " enum_dict = {'Not applicable': -1, 'Not available': 0, 'Bq per m3': 1, 'Bq per kg': 2}\n", - " # unit_type = nc.createEnumType(np.uint8,'unit_t',enum_dict)\n", - " unit_type = nc.createEnumType(np.int_,'unit_t',enum_dict)\n", + "# enum_dict = {'Not applicable': -1, 'Not available': 0, 'Bq per m3': 1, 'Bq per kg': 2}\n", + "# # unit_type = nc.createEnumType(np.uint8,'unit_t',enum_dict)\n", + "# unit_type = nc.createEnumType(np.int_,'unit_t',enum_dict)\n", "\n", - " meas_var = nc.createVariable('measurement', 'f4', 'sample')\n", - " unit_var = nc.createVariable('unit', unit_type, 'sample',\n", - " fill_value=-1\n", - " # fill_value=enum_dict['Not available']\n", - " )\n", + "# meas_var = nc.createVariable('measurement', 'f4', 'sample')\n", + "# unit_var = nc.createVariable('unit', unit_type, 'sample',\n", + "# fill_value=-1\n", + "# # fill_value=enum_dict['Not available']\n", + "# )\n", "\n", - " meas_var[:] = [1.1, 2.1, 3.1, np.nan]\n", - " unit_var[:] = [enum_dict[k] for k in ['Bq per m3', 'Bq per kg', 'Bq per kg']] + [-1]\n", - " print(unit_var)\n", - " # print(unit_var._FillValue)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "36dd4a3f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "nan" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.nan" + "# meas_var[:] = [1.1, 2.1, 3.1, np.nan]\n", + "# unit_var[:] = [enum_dict[k] for k in ['Bq per m3', 'Bq per kg', 'Bq per kg']] + [-1]\n", + "# print(unit_var)" ] }, { diff --git a/nbs/files/cdl.toml b/nbs/files/cdl.toml index 6700ee4..2f47a61 100644 --- a/nbs/files/cdl.toml +++ b/nbs/files/cdl.toml @@ -144,7 +144,7 @@ long_name = "Sediment type" standard_name = "sediment_type_tbd" [vars.suffixes.uncertainty] -name = "unc" +name = "_unc" dtype = "f4" [vars.suffixes.uncertainty.attrs] @@ -152,7 +152,7 @@ long_name = " uncertainty" standard_name = "_uncertainty" [vars.suffixes.detection_limit] -name = "dl" +name = "_dl" dtype = "dl_t" [vars.suffixes.detection_limit.attrs] @@ -160,7 +160,7 @@ long_name = " detection limit" standard_name = "_detection_limit" [vars.suffixes.volume] -name = "vol" +name = "_vol" dtype = "f4" [vars.suffixes.volume.attrs] @@ -168,7 +168,7 @@ long_name = " volume" standard_name = "_volume" [vars.suffixes.salinity] -name = "sal" +name = "_sal" dtype = "f4" [vars.suffixes.salinity.attrs] @@ -176,7 +176,7 @@ long_name = " salinity" standard_name = "_sal" [vars.suffixes.temperature] -name = "temp" +name = "_temp" dtype = "f4" [vars.suffixes.temperature.attrs] @@ -184,7 +184,7 @@ long_name = " temperature" standard_name = "_temp" [vars.suffixes.filtered] -name = "filt" +name = "_filt" dtype = "filt_t" [vars.suffixes.filtered.attrs] @@ -192,7 +192,7 @@ long_name = " filtered" standard_name = "_filtered" [vars.suffixes.counting_method] -name = "counmet" +name = "_counmet" dtype = "counmet_t" [vars.suffixes.counting_method.attrs] @@ -200,7 +200,7 @@ long_name = " counting method" standard_name = "_counting_method" [vars.suffixes.sampling_method] -name = "sampmet" +name = "_sampmet" dtype = "sampmet_t" [vars.suffixes.sampling_method.attrs] @@ -208,7 +208,7 @@ long_name = " sampling method" standard_name = "_sampling_method" [vars.suffixes.preparation_method] -name = "prepmet" +name = "_prepmet" dtype = "prepmet_t" [vars.suffixes.preparation_method.attrs] @@ -216,7 +216,7 @@ long_name = " preparation method" standard_name = "_preparation_method" [vars.suffixes.unit] -name = "unit" +name = "_unit" dtype = "unit_t" [vars.suffixes.unit.attrs] diff --git a/nbs/files/nc/template-test.nc b/nbs/files/nc/template-test.nc index 99672e3..ff6c957 100644 Binary files a/nbs/files/nc/template-test.nc and b/nbs/files/nc/template-test.nc differ diff --git a/nbs/handlers/netcdf_to_csv.ipynb b/nbs/handlers/netcdf_to_csv.ipynb index c70003d..742406a 100644 --- a/nbs/handlers/netcdf_to_csv.ipynb +++ b/nbs/handlers/netcdf_to_csv.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#| default_exp netcdf_to_csv" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/nbs/tutorials/regionalization/3_spatial_analysis.ipynb b/nbs/tutorials/regionalization/3_spatial_analysis.ipynb index 61939a3..75fd91d 100644 --- a/nbs/tutorials/regionalization/3_spatial_analysis.ipynb +++ b/nbs/tutorials/regionalization/3_spatial_analysis.ipynb @@ -41,6 +41,7 @@ "import geopandas as gpd\n", "\n", "from shapely.geometry import Point\n", + "\n", "from pysal.explore import esda\n", "from pysal.lib import weights\n", "\n",