Skip to content

Commit

Permalink
need to update file_conventions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisblake committed Aug 25, 2023
1 parent e342216 commit 56cb1b7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
33 changes: 25 additions & 8 deletions pyaerocom/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
reimport getpass
import getpass
import logging
import os
from configparser import ConfigParser
Expand Down Expand Up @@ -136,7 +136,8 @@ class Config:
CLIM_RESAMPLE_HOW = "mean" # median, ...
# as a function of climatological frequency
CLIM_MIN_COUNT = dict(
daily=30, monthly=5 # at least 30 daily measurements in each month over whole period
daily=30,
monthly=5, # at least 30 daily measurements in each month over whole period
) # analogue to daily ...

# names for the satellite data sets
Expand Down Expand Up @@ -176,7 +177,11 @@ class Config:

# this dictionary links environment ID's with corresponding subdirectory
# names that are required to exist in order to load this environment
_check_subdirs_cfg = {"metno": "aerocom", "users-db": "AMAP", "local-db": "modeldata"}
_check_subdirs_cfg = {
"metno": "aerocom",
"users-db": "AMAP",
"local-db": "modeldata",
}

with resources.path("pyaerocom.data", "variables.ini") as path:
_var_info_file = str(path)
Expand Down Expand Up @@ -229,7 +234,9 @@ def __init__(self, config_file=None, try_infer_environment=True):

if config_file is not None:
if not os.path.exists(config_file):
raise FileNotFoundError(f"input config file does not exist {config_file}")
raise FileNotFoundError(
f"input config file does not exist {config_file}"
)
elif not config_file.endswith("ini"):
raise ValueError("Need path to an ini file for input config_file")

Expand Down Expand Up @@ -406,7 +413,9 @@ def DOWNLOAD_DATADIR(self, val):
try:
os.mkdir(val)
except Exception:
raise OSError(f"Input directory {val} does not exist and can also not be created")
raise OSError(

Check warning on line 416 in pyaerocom/config.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/config.py#L416

Added line #L416 was not covered by tests
f"Input directory {val} does not exist and can also not be created"
)
self._downloaddatadir = val

@property
Expand Down Expand Up @@ -439,7 +448,9 @@ def CACHEDIR(self):
try:
return chk_make_subdir(self.cache_basedir, self.user)
except Exception as e:
logger.warning(f"Failed to access CACHEDIR: {repr(e)}\nDeactivating caching")
logger.warning(

Check warning on line 451 in pyaerocom/config.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/config.py#L451

Added line #L451 was not covered by tests
f"Failed to access CACHEDIR: {repr(e)}\nDeactivating caching"
)
self._caching_active = False

@CACHEDIR.setter
Expand Down Expand Up @@ -467,7 +478,9 @@ def CACHING(self, val):
@property
def VAR_PARAM(self):
"""Deprecated name, please use :attr:`VARS` instead"""
logger.warning("Deprecated (but still functional) name VAR_PARAM. Please use VARS")
logger.warning(
"Deprecated (but still functional) name VAR_PARAM. Please use VARS"
)
return self.VARS

@property
Expand Down Expand Up @@ -717,7 +730,11 @@ def reload(self, keep_basedirs=True):
self.read_config(self.last_config_file, keep_basedirs)

def read_config(
self, config_file, basedir=None, init_obslocs_ungridded=False, init_data_search_dirs=False
self,
config_file,
basedir=None,
init_obslocs_ungridded=False,
init_data_search_dirs=False,
):
"""
Import paths from one of the config ini files
Expand Down
4 changes: 4 additions & 0 deletions pyaerocom/data/file_conventions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ year_pos=-2
var_pos=-3
ts_pos=-4
data_id_pos=1

[cso]
file_sep=_
year_pos=-3
1 change: 0 additions & 1 deletion pyaerocom/io/fileconventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(
data_id_pos=None,
from_file=None,
):

self.name = name
self.file_sep = file_sep

Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/io/readgridded.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@ def _update_file_convention(self, files):
FileNotFoundError
if none of the input files matches a registered convention.
"""
breakpoint()
for file in files:
try:
self.file_convention.from_file(os.path.basename(file))
return
except Exception:
breakpoint()

Check warning on line 702 in pyaerocom/io/readgridded.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/io/readgridded.py#L702

Added line #L702 was not covered by tests
pass

raise FileNotFoundError(
Expand Down
12 changes: 6 additions & 6 deletions pyaerocom/plugins/tropomi/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
"value",
)

TMP_DATA_DIR = (
"/lustre/storeB/project/fou/kl/sesam/archive/CSO-gridded/xEMEP__r01x01__qa08/NO2/2023/01"
)
TMP_DATA_DIR = "/lustre/storeB/project/fou/kl/sesam/archive/CSO-gridded/xEMEP__r01x01__qa08/NO2/2022/10/"

Check warning on line 33 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L33

Added line #L33 was not covered by tests


class ReadTropomiL3(ReadGridded):

Check warning on line 36 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L36

Added line #L36 was not covered by tests
Expand All @@ -41,13 +39,15 @@ class ReadTropomiL3(ReadGridded):
e.g., Tropospheric vertical column of nitrogen dioxide
"""

_FILEMASK = "S5p_*.nc"
_FILEMASK = "CSO_output_*_gridded.nc"
__version__ = "0.01"

Check warning on line 43 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L42-L43

Added lines #L42 - L43 were not covered by tests

DATA_ID = const.TROPOMI_NAME

Check warning on line 45 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L45

Added line #L45 was not covered by tests

def __init__(self, data_id=None, data_dir=None):
if data_dir is None:
data_dir = TMP_DATA_DIR
# raise Exception("Need a data_dir")
super().__init__(data_dir=data_dir)
breakpoint()

Check warning on line 50 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L47-L50

Added lines #L47 - L50 were not covered by tests
# raise Exception("Need a data_dir")
super().__init__(data_dir=data_dir, file_convention="cso")
breakpoint()

Check warning on line 53 in pyaerocom/plugins/tropomi/reader.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/plugins/tropomi/reader.py#L52-L53

Added lines #L52 - L53 were not covered by tests

0 comments on commit 56cb1b7

Please sign in to comment.