Skip to content
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

More work on internal data structures #269

Merged
merged 77 commits into from
Nov 19, 2023
Merged

More work on internal data structures #269

merged 77 commits into from
Nov 19, 2023

Conversation

jsmariegaard
Copy link
Member

@jsmariegaard jsmariegaard commented Sep 29, 2023

  • Consistent representation of quantity
  • Consistent representation of x, y, z
  • Move time interpolation - postponed to later PR

and a lot of cleaning, restructuring etc

Sorry, something went wrong.

@jsmariegaard jsmariegaard marked this pull request as ready for review October 8, 2023 19:23
Copy link
Member

@ecomodeller ecomodeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good in general.

Do we need this logic in the Comparer

if not isinstance(other, (Comparer, ComparerCollection)):
raise TypeError(f"Cannot add {type(other)} to {type(self)}")
if isinstance(other, Comparer) and (self.name == other.name):
assert type(self) == type(other), "Must be same type!"
missing_models = set(self.mod_names) - set(other.mod_names)
if len(missing_models) == 0:
# same obs name and same model names
cmp = self.copy()
cmp.data = xr.concat([cmp.data, other.data], dim="time")
# cc.data = cc.data[
# ~cc.data.time.to_index().duplicated(keep="last")
# ] # 'first'
_, index = np.unique(cmp.data["time"], return_index=True)
cmp.data = cmp.data.isel(time=index)
else:
raw_mod_data = self.raw_mod_data.copy()
raw_mod_data.update(other.raw_mod_data)
matched = match_time(
observation=self._to_observation(), raw_mod_data=raw_mod_data
)
cmp = self.__class__(matched_data=matched, raw_mod_data=raw_mod_data)
return cmp
else:

Isn't this taken care of already by the ComparerCollection?

If so, then we could also get rid of Comparer._to_observation()

@jsmariegaard jsmariegaard self-assigned this Nov 19, 2023
@jsmariegaard jsmariegaard merged commit d09b54b into main Nov 19, 2023
@jsmariegaard jsmariegaard deleted the matching-refactor branch November 19, 2023 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants