Skip to content

Commit

Permalink
Added fix for extracting index from dataArray
Browse files Browse the repository at this point in the history
  • Loading branch information
mrghg committed Apr 19, 2024
1 parent 0c57cca commit 29688ba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion openghg_calscales/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ def convert(c, species, scale_original, scale_new):
except:
raise ValueError(f"Conversion function {fx*ft} is not valid.")

# Calculate decimal date
if isinstance(c, pd.Series):
dec_date = _decimal_date(c.index)
elif isinstance(c, xr.DataArray):
dec_date = _decimal_date(c.time.to_index())

c_out = c.copy()
c_out[:] = fn(c.values, _decimal_date(c.index))
c_out[:] = fn(c.values, dec_date)

return c_out

0 comments on commit 29688ba

Please sign in to comment.