-
Notifications
You must be signed in to change notification settings - Fork 3
dataextractor update for numpy 2.0 #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,12 @@ def __init__(self, top: Real, bottom: Real): | |
| self.__bottom = b | ||
|
|
||
| def __repr__(self): | ||
| return f"Layer({self.__top}, {self.__bottom})" | ||
| return f"{self.__class__.__name__}({self.__top}, {self.__bottom})" | ||
|
|
||
| def __str__(self): | ||
| if self.top == self.bottom: | ||
| return f"Layer {self.__top} m" | ||
| return f"Layer {self.__top:g}-{self.__bottom:g} m" | ||
| return f"{self.__class__.__name__} {self.__top} m" | ||
| return f"{self.__class__.__name__} {self.__top:g}-{self.__bottom:g} m" | ||
|
|
||
| def __eq__(self, other): | ||
| if not isinstance(other, Layer): | ||
|
|
@@ -54,49 +54,15 @@ def bottom(self): | |
| return self.__bottom | ||
|
|
||
|
|
||
| class LayerMap(object): | ||
| def __init__(self, mask, top, bottom): | ||
| if (top.shape == mask.shape[1:]) & (bottom.shape == mask.shape[1:]): | ||
| self.__mask = mask | ||
| self.__dim = mask.shape[1:] | ||
| else: | ||
| raise ValueError( | ||
| "top and bottom dimensions must be equal to mask dimensions along lat and lon" | ||
| ) | ||
|
|
||
| if np.all(top <= bottom): | ||
| self.__top = top | ||
| self.__bottom = bottom | ||
| else: | ||
| raise ValueError("top must be above of bottom") | ||
|
|
||
| def __repr__(self): | ||
| return "Map of Layers with dimensions %g,%g" % ( | ||
| self.__dim[0], | ||
| self.__dim[1], | ||
| ) | ||
|
|
||
| def __str__(self): | ||
| return "maplayer(%g,%g)" % (self.__dim[0], self.__dim[1]) | ||
|
|
||
| def string(self): | ||
| return "maplayer(%g,%g)" % (self.__dim[0], self.__dim[1]) | ||
|
|
||
| def longname(self): | ||
| return "Map of Layers, dimension %g,%g" % (self.__dim[0], self.__dim[1]) | ||
|
|
||
| @property | ||
| def top(self): | ||
| return self.__top | ||
|
|
||
| @property | ||
| def bottom(self): | ||
| return self.__bottom | ||
| class LayerMap(Layer): | ||
|
||
| def __init__(self, mask, top: Real, bottom: Real): | ||
| super().__init__(top, bottom) | ||
| self.__mask = mask | ||
|
|
||
| @property | ||
| def mask(self): | ||
| return self.__mask | ||
|
|
||
| @property | ||
| def dimension(self): | ||
| return self.__dim | ||
| return self.__mask.shape[1:] | ||
|
Comment on lines
+57
to
+68
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fill value detection logic has been simplified to use
get_fill_value()with a fallback to_FillValueattribute. However, this may not handle all the cases that the original code covered.The original code checked multiple attribute names:
"missing_value","fillvalue","fillValue","FillValue". The new approach only usesget_fill_value()(which typically checks_FillValue,missing_value, and the variable's fill value in that order depending on the netCDF4 version) and falls back to_FillValueifget_fill_value()is not available.This could miss cases where the fill value is stored under alternative attribute names like
"fillvalue"(lowercase) or"fillValue"(camelCase), which may exist in some NetCDF files for backwards compatibility.