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

Hybrid pressure #46

Merged
merged 1 commit into from
Aug 31, 2012
Merged

Hybrid pressure #46

merged 1 commit into from
Aug 31, 2012

Conversation

rhattersley
Copy link
Member

Key features:

  1. A hybrid-pressure representation.
  2. PP loader now deals with time-varying references.
  3. Linear interpolation enhanced to support more general re-gridding of reference surfaces.

@@ -473,7 +473,9 @@ def add_dim_coord(self, dim_coord, data_dim=None):

# Check compatibility with the shape of the data
if dim_coord.shape[0] != self.shape[data_dim]:
raise ValueError('The length of %r does not match the length of cube dimension %d' % (dim_coord, data_dim))
msg = 'Incompatible lengths: cube dimension {} => {}; {} => {}.'
raise ValueError(msg.format(data_dim, self.shape[data_dim],
Copy link
Member

Choose a reason for hiding this comment

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

We can more be more explicit and say that the lengths are unequal rather than incompatible. Saying they are incompatible may not help the user understand the problem (i.e. they are not equal).

Copy link
Member

Choose a reason for hiding this comment

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

Exception message on line 412 (in Cube.add_aux_coord()) should match this message.

@esc24
Copy link
Member

esc24 commented Aug 22, 2012

As an aside, orography (and surface pressure) are coordinates so they cannot (currently) have missing data. It seems reasonable that they might, so would any changes be needed to handle this appropriately. My gut tells me careful scattering of orography.points.filled(0) might do it.

if len(reference_cubes[arg.name]) > 1:
all = iris.cube.CubeList(reference_cubes[arg.name])
reference_cubes[arg.name] = all.merge()
src = reference_cubes[arg.name][0]
Copy link
Member

Choose a reason for hiding this comment

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

Why do you take the first cube in the list rather than the last (as before)? If the merge can't find anything to merge and does nothing, you are changing the behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I'd been assuming the merge would be successful. I'll add a warning if the merge wasn't completely successful (i.e. it resulted in more than one cube), and make sure I always pick the last one.

@esc24
Copy link
Member

esc24 commented Aug 23, 2012

This PR is associated with #1.

@rhattersley
Copy link
Member Author

The missing-data-in-coordinates issue should be taken care of by the higher precedence of masked arrays. ie. my_plain_old_array + my_masked_array => another_masked_array

@rhattersley
Copy link
Member Author

Rebased - ready for review.

@@ -1008,9 +1011,12 @@ def is_monotonic(self):
class AuxCoord(Coord):
"""A CF auxiliary coordinate."""
@staticmethod
def from_coord(coord):
def from_coord(coord, points=None):
Copy link
Member

Choose a reason for hiding this comment

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

I don't like this. It'll blow up if the points are incompatible with the bounds of the source coord. I know you could add a further bounds arg and implement the same logic of wiping bounds if only points are provided, but I'm not keen on adding arguments (or this logic) as it'll encourage use of this somewhat questionable method (I know I created it the first place!). If you just want the coord's metadata (which is the case if you are providing alternative points and bounds) then I'd prefer something like:

new_coord = AuxCoord(new_points)
new_coord.metadata = old_coord.metadata

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed - especially as it's only used in one place (interpolation).

@bblay
Copy link
Contributor

bblay commented Aug 31, 2012

I think this is a side-effect of an artificial separation of AuxCoord from Coord.

factory=factory_name))
warnings.warn(msg.format(filenames=filenames,
factory=factory_name))
break
Copy link
Member

Choose a reason for hiding this comment

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

Why do you break here? A continue (or equivalently nothing at all) seems like a better idea as you might be able to make other factories of the cube.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. The break is a hangover from the old in-line code.

@esc24
Copy link
Member

esc24 commented Aug 31, 2012

Nearly there. @rhattersley - should we squash it all into a single commit for merging to keep the history on master a little cleaner?

@rhattersley
Copy link
Member Author

Given the convoluted mess I think a bit of a squash is in order.

Merge time-varying reference cubes, and upgrade interpolation to cope.
Units checking in hybrid coordinate constructors.
esc24 added a commit that referenced this pull request Aug 31, 2012
@esc24 esc24 merged commit 00c936e into SciTools:master Aug 31, 2012
@esc24 esc24 mentioned this pull request Sep 10, 2012
marqh pushed a commit that referenced this pull request Feb 16, 2017
* header dates corrected whitespace removed
bjlittle pushed a commit that referenced this pull request Feb 23, 2017
* header dates corrected whitespace removed
bjlittle referenced this pull request in bjlittle/iris May 31, 2017
* header dates corrected whitespace removed
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

3 participants