Skip to content

Commit

Permalink
don't add units to the header when there are none
Browse files Browse the repository at this point in the history
(some indices computation like frequency don't have any unit
and having an empty pair of parenthesis is awkward)
  • Loading branch information
davidcaron committed May 23, 2019
1 parent 5ee9fc7 commit e416674
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion finch/processes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ def netcdf_to_csv(
for variable in ds.data_vars:
model = ds.attrs["driving_model_id"]
experiment = ds.attrs["driving_experiment_id"].replace(",", "_")

output_variable = f"{variable}_{model}_{experiment}"

units = ds[variable].units
if units:
output_variable += f"_({units})"

output_variable = f"{variable}_{model}_{experiment}_({units})"
ds = ds.rename({variable: output_variable})

df = ds.to_dataframe()[["lat", "lon", output_variable]]
Expand Down

0 comments on commit e416674

Please sign in to comment.