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

Global Total Integrated primary production derived variable #270

Closed
wants to merge 2 commits into from

Conversation

ledm
Copy link
Contributor

@ledm ledm commented Sep 24, 2019

This PR brings in the Global Total Integrated primary production derived variable. This variable has appeared in the upcoming ESMValTool Paper - part 2, so it would be nice to get it out there before the publication gets to discussions format.

This is linked with the ESMValTool PR ESMValGroup/ESMValTool#1331, which uses this derived field.

@mattiarighi mattiarighi added the variable derivation Related to variable derivation functions label Sep 24, 2019
@ledm ledm requested a review from valeriupredoi September 24, 2019 10:03
@@ -107,15 +107,22 @@ def _put_in_cube(template_cube, cube_data, statistic, t_axis):
t_axis,
standard_name='time',
units=template_cube.coord('time').units)
lats = template_cube.coord('latitude')
lons = template_cube.coord('longitude')

Copy link
Member

Choose a reason for hiding this comment

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

These changes seem unrelated to deriving the variable? Would it make sense to put this in a separate pull request?


try:
cube_area = cubes.extract_strict(iris.Constraint(name='cell_area'))
except iris.exceptions.ConstraintMismatchError:
Copy link
Member

Choose a reason for hiding this comment

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

If this happens, cube_area will be undefined and the code below will fail, so I think it is not a good idea to let this pass

iris.analysis.MEAN,
)

# TODO: Load seconds per year from model calendar.
Copy link
Member

Choose a reason for hiding this comment

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

Do your to do?

times = intpp_cube.coord('time')

intpp_cube.data = np.ma.array(intpp_cube.data)
for time_itr in np.arange(len(times.points)):
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use iris.analysis.SUM to aggregate over the required dimensions?

Copy link
Member

@bouweandela bouweandela left a comment

Choose a reason for hiding this comment

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

Could you please add a unit test too?

@mattiarighi
Copy link
Contributor

@ledm can you finalize this PR so that I can test it?

Copy link

@znicholls znicholls left a comment

Choose a reason for hiding this comment

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

Following the logic of #331, is this now redundant? This could be specified in a recipe using a combination of fx weighting, the area information and the sum preprocessor?

This PR can thus be closed?

@znicholls
Copy link

The fact that the derived variable's units lose the per m2 is related to the comment here #1574 (comment)

In other words, the fact that a sum weighted by area does not include units (i.e. by multiplying the units by area ** 2) is an ongoing issue (issue now open at #1613 to track)

@schlunma
Copy link
Contributor

schlunma commented Apr 2, 2024

I think this can now be done with the following preprocessor:

area_statistics:
  operator: sum

(including correct unit handling).

Please re-open if necessary.

@schlunma schlunma closed this Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
variable derivation Related to variable derivation functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants