Skip to content

Commit

Permalink
set decode_times to false
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMortier committed Sep 19, 2024
1 parent ed2533a commit 898c203
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion aprofiles/cli/aprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def main(

# list all files in out directory
datepath = Path(basedir_out, yyyy, mm, dd)
onlyfiles = [str(e) for e in datepath.iterdir() if e.is_file()]

if update_calendar:
# create calendar
Expand All @@ -134,6 +133,8 @@ def main(
if not path.is_file():
utils.json_calendar.make_calendar(basedir_out, yyyy, mm, calname)

# list all files in out directory
onlyfiles = [str(e) for e in datepath.iterdir() if e.is_file()]
# add to calendar
for file in tqdm(onlyfiles, desc="calendar ", disable=disable_progress_bar):
utils.json_calendar.add_to_calendar(file, basedir_out, yyyy, mm, dd, calname)
Expand All @@ -146,11 +147,15 @@ def main(
if not path.is_file():
utils.json_map.make_map(basedir_out, yyyy, mm, mapname)

# list all files in out directory
onlyfiles = [str(e) for e in datepath.iterdir() if e.is_file()]
# add to map
for file in tqdm(onlyfiles, desc="map ", disable=disable_progress_bar):
utils.json_map.add_to_map(file, basedir_out, yyyy, mm, dd, mapname)

if update_climatology:
# list all files in out directory
onlyfiles = [str(e) for e in datepath.iterdir() if e.is_file()]
# get station id from file name
stations_id = ["-".join(onlyfile.split("/")[-1].split("AP_")[1].split("-", 5)[:5]) for onlyfile in onlyfiles]
# exclude moving stations
Expand Down
8 changes: 5 additions & 3 deletions aprofiles/cli/utils/json_climatology.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def compute_climatology(basedir, station_id, variables, aerosols_only):
if station_id in file and file.endswith(".nc"):
station_files.append(os.path.join(root, file))

print(station_files)

try:
# open dataset with xarray
ds = xr.open_mfdataset(station_files, parallel=False)
ds = xr.open_mfdataset(station_files, parallel=False, decode_times=False)

# convert time index
ds = convert_time_int_to_datetime(ds)
Expand All @@ -51,9 +53,9 @@ def compute_climatology(basedir, station_id, variables, aerosols_only):
attrs["today"] = datetime.today().strftime("%Y-%m-%d")

# seasonal resampling
Qds = ds.resample(time="Q").mean()
Qds = ds.resample(time="QE").mean()
# add number of days per season as a new variable
Qds["ndays"] = ds.scene.resample(time="D").count().resample(time="Q").count()
Qds["ndays"] = ds.scene.resample(time="D").count().resample(time="QE").count()

# work with selected variable

Expand Down

0 comments on commit 898c203

Please sign in to comment.