Skip to content

Commit

Permalink
correct profile output
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisblake committed Jul 22, 2023
1 parent 0f0b541 commit 7fb61b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pyaerocom/aeroval/coldatatojson_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
update_regions_json,
process_profile_data,
get_profile_filename,
add_profile_entry_json,
)
from pyaerocom.exceptions import AeroValConfigError, TemporalResolutionError

Expand Down Expand Up @@ -300,9 +301,8 @@ def process_coldata(self, coldata: ColocatedData):

fname = get_profile_filename(regid, obs_name, var_name_web)

add_profile_entry_json(fname, data, profile_viz, periods, seasons)

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

# for reg in regions:
# fname = get_profile_filename(reg, obs_name, var_name_web)
Expand Down
17 changes: 10 additions & 7 deletions pyaerocom/aeroval/coldatatojson_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ def process_profile_data(
periods,
seasons,
):
breakpoint()
# breakpoint()
# basically need to do something like process_heatmap_data
output = {"obs": {}, "mod": {}}
# stats_dummy = _init_stats_dummy()
Expand Down Expand Up @@ -1467,7 +1467,10 @@ def add_profile_entry_json(profile_file, data, profile_viz, periods, seasons):
current[model_name]["z"] = [
0
] # initalize with 0 # LB: try writing this to a list and see is simple_json complains
current[model_name]["z"].append(coldata.data.attrs["vertical_layer"]["end"])
if (
coldata.data.attrs["vertical_layer"]["end"] > current[model_name]["z"][-1]
): # only store incremental increases in the layers
current[model_name]["z"].append(coldata.data.attrs["vertical_layer"]["end"])

if not "obs" in current[model_name]:
current[model_name]["obs"] = {}
Expand All @@ -1476,7 +1479,7 @@ def add_profile_entry_json(profile_file, data, profile_viz, periods, seasons):
current[model_name]["obs"][freq] = {}

if not "mod" in current[model_name]:
current[model_name]["mod"][freq] = {}
current[model_name]["mod"] = {}

if not freq in current[model_name]["mod"]:
current[model_name]["mod"][freq] = {}
Expand All @@ -1486,12 +1489,12 @@ def add_profile_entry_json(profile_file, data, profile_viz, periods, seasons):
perstr = f"{per}-{season}"

if not perstr in current[model_name]["obs"][freq]:
current[model_name]["obs"][freq] = []
current[model_name]["obs"][freq][perstr] = []
if not perstr in current[model_name]["mod"][freq]:
current[model_name]["mod"][freq] = []
current[model_name]["mod"][freq][perstr] = []

current[model_name]["obs"][freq].append(profile_viz["obs"][freq][perstr])
current[model_name]["mod"][freq].append(profile_viz["mod"][freq][perstr])
current[model_name]["obs"][freq][perstr].append(profile_viz["obs"][freq][perstr])
current[model_name]["mod"][freq][perstr].append(profile_viz["mod"][freq][perstr])

if not "metadata" in current[model_name]:
# should be same for all. hardcoded because no way to pass this all along now
Expand Down

0 comments on commit 7fb61b0

Please sign in to comment.