Skip to content

Commit

Permalink
Merge pull request #22 from metno/20-put-the-right-time-step-length-i…
Browse files Browse the repository at this point in the history
…n-the-difference-between-start-and-stop-time

Put the right time step length in the difference between start and stop time
  • Loading branch information
jgriesfeller authored Jan 2, 2024
2 parents 3c721ed + 6c28e13 commit 22ca00a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ts.data('AOD_550nm')['stations']
# start_times
ts.data('AOD_550nm')['start_times']
# stop_times
ts.data('AOD_550nm')['stop_times']
ts.data('AOD_550nm')['end_times']
# latitudes
ts.data('AOD_550nm')['latitudes']
# longitudes
Expand All @@ -57,7 +57,7 @@ ts.data('AODGT1_550nm')['stations']
# start_times
ts.data('AODGT1_550nm')['start_times']
# stop_times
ts.data('AODGT1_550nm')['stop_times']
ts.data('AODGT1_550nm')['end_times']
# latitudes
ts.data('AODGT1_550nm')['latitudes']
# longitudes
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyaro_readers"
version = "0.0.2"
version = "0.0.3"
authors = [{ name = "MET Norway" }]
description = "implementations of pyaerocom reading plugings using pyaro as interface'"
readme = "README.md"
Expand Down
13 changes: 11 additions & 2 deletions src/pyaro_readers/aeronetsdareader/AeronetSdaTimeseriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@

FILE_MASK = "*.ONEILL_lev*"

TS_TYPE_DIFFS = {
"daily": np.timedelta64(12, "h"),
"instantaneous": np.timedelta64(0, "s"),
"points": np.timedelta64(0, "s"),
"monthly": np.timedelta64(15, "D"),
}


class AeronetSdaTimeseriesReader(AutoFilterReaderEngine.AutoFilterReader):
def __init__(
Expand All @@ -67,6 +74,7 @@ def __init__(
filters=[],
fill_country_flag: bool = FILL_COUNTRY_FLAG,
tqdm_desc: [str, None] = None,
ts_type: str = "daily",
):
"""open a new csv timeseries-reader
Expand Down Expand Up @@ -209,8 +217,9 @@ def __init__(
day, month, year = row[DATE_NAME].split(":")
datestring = "-".join([year, month, day])
datestring = "T".join([datestring, row[TIME_NAME]])
start = np.datetime64(datestring)
end = start
time_dummy = np.datetime64(datestring)
start = time_dummy - TS_TYPE_DIFFS[ts_type]
end = time_dummy + TS_TYPE_DIFFS[ts_type]

ts_dummy_data = {}
for variable in DATA_VARS:
Expand Down
17 changes: 13 additions & 4 deletions src/pyaro_readers/aeronetsunreader/AeronetSunTimeseriesReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@

FILL_COUNTRY_FLAG = False

TS_TYPE_DIFFS = {
"daily": np.timedelta64(12, "h"),
"instantaneous": np.timedelta64(0, "s"),
"points": np.timedelta64(0, "s"),
"monthly": np.timedelta64(15, "D"),
}


class AeronetSunTimeseriesReader(AutoFilterReaderEngine.AutoFilterReader):
def __init__(
Expand All @@ -56,16 +63,17 @@ def __init__(
filters=[],
fill_country_flag: bool = FILL_COUNTRY_FLAG,
tqdm_desc: [str, None] = None,
ts_type: str = "daily",
):
"""open a new csv timeseries-reader
"""open a new Aeronet timeseries-reader
:param filename: str
:param filters:
:param fill_country_flag:
:param tqdm_desc:
:param filename_or_obj_or_url: path-like object to csv-file
input file looks like this:
input file looks like this (daily file; times noted are middle times):
AERONET Version 3;
Cuiaba
Version 3: AOD Level 2.0
Expand Down Expand Up @@ -157,8 +165,9 @@ def __init__(
day, month, year = row[DATE_NAME].split(":")
datestring = "-".join([year, month, day])
datestring = "T".join([datestring, row[TIME_NAME]])
start = np.datetime64(datestring)
end = start
time_dummy = np.datetime64(datestring)
start = time_dummy - TS_TYPE_DIFFS[ts_type]
end = time_dummy + TS_TYPE_DIFFS[ts_type]

ts_dummy_data = {}
for variable in DATA_VARS:
Expand Down

0 comments on commit 22ca00a

Please sign in to comment.