Skip to content

Commit

Permalink
separate profiles by station_name
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisblake committed Jul 24, 2023
1 parent a67752a commit 98593e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
9 changes: 5 additions & 4 deletions pyaerocom/aeroval/coldatatojson_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,19 @@ def process_coldata(self, coldata: ColocatedData):
): # LB: Will need some sort of additional flag to deal with the two colocation level types
logger.info("Processing profile data for vizualization")

for regid in regnames:
# for regid in regnames:
for station_name in coldata.data.station_name.values:
profile_viz = process_profile_data(
data,
regid,
station_name,
use_country,
periods,
seasons,
)

fname = get_profile_filename(regid, obs_name, var_name_web)
fname = get_profile_filename(station_name, obs_name, var_name_web)

outfile_profile = os.path.join(out_dirs["profile"], fname)
outfile_profile = os.path.join(out_dirs["profiles"], fname)
add_profile_entry_json(outfile_profile, data, profile_viz, periods, seasons)

# for reg in regions:
Expand Down
25 changes: 16 additions & 9 deletions pyaerocom/aeroval/coldatatojson_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,14 @@ def _start_stop_from_periods(periods):
return start_stop(start, stop + 1)


def get_profile_filename(region, obs_name, var_name_web):
return f"{region}_{obs_name}_{var_name_web}.json"
def get_profile_filename(station_name, obs_name, var_name_web):
return f"{station_name}_{obs_name}_{var_name_web}.json"


def process_profile_data(
data,
region_id,
# region_id,
station_name,
use_country,
periods,
seasons,
Expand All @@ -1397,7 +1398,11 @@ def process_profile_data(
output["mod"][freq][perstr] = np.nan
else:
try:
subset = _select_period_season_coldata(coldata, per, season)
all_stations_subset = _select_period_season_coldata(coldata, per, season)
station_subset = all_stations_subset.data[
:, :, all_stations_subset.data.station_name.values == station_name
]
# subset = _select_period_season_coldata(coldata, per, season)

# trends_successful = False
# if add_trends and freq != "daily":
Expand All @@ -1406,9 +1411,9 @@ def process_profile_data(

# if stop - start >= trends_min_yrs:
# try:
subset_time_series = subset.get_regional_timeseries(
region_id, check_country_meta=use_country
)
# subset_time_series = subset.get_regional_timeseries(
# region_id, check_country_meta=use_country
# )

# (obs_trend, mod_trend) = _make_trends_from_timeseries(
# subset_time_series["obs"],
Expand All @@ -1422,8 +1427,10 @@ def process_profile_data(

# trends_successful = True

output["obs"][freq][perstr] = np.nanmean(subset_time_series["obs"])
output["mod"][freq][perstr] = np.nanmean(subset_time_series["mod"])
# output["obs"][freq][perstr] = np.nanmean(subset_time_series["obs"])
# output["mod"][freq][perstr] = np.nanmean(subset_time_series["mod"])
output["obs"][freq][perstr] = np.nanmean(station_subset.data[0, :, :])
output["mod"][freq][perstr] = np.nanmean(station_subset.data[1, :, :])
except:
msg = f"Failed to access subset timeseries, and will skip."
logger.warning(msg)
Expand Down

0 comments on commit 98593e1

Please sign in to comment.