Skip to content

Commit

Permalink
Fix xoa.sigma.get_cs to keep it compatible with pure numpy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
stefraynaud committed Jul 21, 2023
1 parent c90f72e commit 989c8bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
13 changes: 5 additions & 8 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ What's new
##########


In development (XXX-XX-XX)
==========================
0.7.1 (2023-07-21)
==================

New features
------------
- Add support for not creating multi-indexes in :func:`xoa.coords.geo_stack`.

Breaking changes
----------------

Deprecations
------------

Bug fixes
---------
- Fix :func:`xoa.geo.get_distances` that was not able to handle multi-indexes from :func:`xoa.coords.geo_stack`.
- Fix doc generation [:pull:`83`].
- Fix :func:`xoa.sigma.get_cs` to keep it compatible with pure numpy arrays


Documentation
-------------
- Add a link to the github repository.


0.7.0 (2023-07-17)
Expand Down
7 changes: 1 addition & 6 deletions xoa/sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def get_cs(sig, thetas, thetab, cs_type=None):
s, a, b = sig, thetas, thetab
cs = np.sinh(s * a) * (1 - b) / np.sinh(a)
cs = cs + b * (np.tanh(a * (s + 0.5)) / (2 * np.tanh(0.5 * a)) - 0.5)
cs.name = None
if hasattr(cs, "coords"):
cs.name = None
cs = cf.get_cf_specs(sig).format_data_var(cs, "cs", format_coords=False, rename_dims=False)
return cs

Expand Down Expand Up @@ -628,7 +628,6 @@ def get_sigma_terms(ds, vloc=None, hlocs=None, rename=False):
sigs = cfspecs.search(ds, 'sig', loc=vloc, single=False)
terms = {}
for sig in sigs:

# Check standard_name and get loc
if "standard_name" not in sig.attrs:
raise XoaSigmaError(
Expand All @@ -648,11 +647,9 @@ def get_sigma_terms(ds, vloc=None, hlocs=None, rename=False):
# Loop in horizontal locations
subterms = terms[loc] = {}
for hloc in hlocs:

# Check terms
subsubterms = subterms[hloc] = {sig.name: "sig", "type": standard_name}
for fname, fvname in formula_terms.items():

# xoa.cf name
# TODO: handle mising cs and fallback with thetas and thetab
if fname.lower() not in FORMULA_TERMS_TO_CF_NAMES:
Expand Down Expand Up @@ -742,9 +739,7 @@ def decode_cf_sigma(ds, rename=False, hlocs=None, errors="raise"):
if hsingle:
hlocs = [hlocs]
for vloc, vterms in all_terms.items():

for hloc in hlocs:

terms = vterms if hsingle else vterms[hloc]
hloc = cfspecs.sglocator.parse_loc_arg(hloc)
sigma_type = terms.pop("type")
Expand Down

0 comments on commit 989c8bc

Please sign in to comment.