Skip to content

Commit

Permalink
Merge pull request #685 from metno/charlienegri-patch-1
Browse files Browse the repository at this point in the history
extract periods from date range, add new models
  • Loading branch information
charlienegri authored Jun 28, 2022
2 parents 64936a0 + 59ab0cd commit ffa606f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
8 changes: 5 additions & 3 deletions pyaerocom/io/cams2_83/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@


class ModelName(str, Enum):
EMEP = "emep"
CHIMERE = "chimere"
DEHM = "dehm"
EMEP = "emep"
EURAD = "euradim"
GEMAQ = "gemaq"
LOTOS = "lotos"
MATCH = "match"
SILAM = "silam"
MINNI = "minni"
MOCAGE = "mocage"
CHIMERE = "chimere"
MONARCH = "monarch"
SILAM = "silam"
ENSEMBLE = "ensemble"

def __str__(self) -> str:
Expand Down
27 changes: 21 additions & 6 deletions pyaerocom/scripts/cams2_83/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,28 @@ def make_period(
start_date: datetime,
end_date: datetime,
) -> List[str]:
start_yr = start_date.strftime("%Y%m%d") # .year
end_yr = end_date.strftime("%Y%m%d") # .year
start_yr = start_date.year
end_yr = end_date.year
start_dt = start_date.strftime("%Y%m%d") # .year
end_dt = end_date.strftime("%Y%m%d") # .year

if start_dt == end_dt:
return [f"{start_dt}"]

periods = [f"{start_dt}-{end_dt}"]
if end_yr == start_yr:
return periods

periods.append(f"{start_dt}-{start_yr}1231") # append first year portion

if (end_yr - start_yr) >= 2 : # append full years in between if any
for y in range(start_yr+1,end_yr):
periods.append(f"{y}0101-{y}1231")

periods.append(f"{end_yr}0101-{end_dt}") # append last year portion

return periods

if start_yr == end_yr:
return [f"{start_yr}"]

return [f"{start_yr}-{end_yr}"]


def date_range(start_date: datetime | date, end_date: datetime | date) -> tuple[date, ...]:
Expand Down
2 changes: 1 addition & 1 deletion pyaerocom/scripts/cams2_83/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
clear_existing_json=False,
# if True, the analysis will stop whenever an error occurs (else, errors that
# occurred will be written into the logfiles)
raise_exceptions=True,
raise_exceptions=False,
# options for CAMS2-83
use_cams2_83=True,
# cams2_83_model=ModelName.EMEP,
Expand Down

0 comments on commit ffa606f

Please sign in to comment.