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

Add flash age compositor for li instruments #2895

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ClementLaplace
Copy link
Contributor

@ClementLaplace ClementLaplace commented Sep 4, 2024

This Merge request is there to create the flash age compositor related to the li instrument.

  • Add the flash_age compositor feature
  • Document the code related to the feature
  • Test the flash_age compositor

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.07%. Comparing base (084b114) to head (3edf893).
Report is 429 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2895    +/-   ##
========================================
  Coverage   96.06%   96.07%            
========================================
  Files         370      375     +5     
  Lines       54320    54474   +154     
========================================
+ Hits        52185    52335   +150     
- Misses       2135     2139     +4     
Flag Coverage Δ
behaviourtests 3.98% <0.00%> (-0.02%) ⬇️
unittests 96.16% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Sep 4, 2024

Pull Request Test Coverage Report for Build 10700852657

Details

  • 18 of 34 (52.94%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on add_flash_age_compositor at 96.124%

Changes Missing Coverage Covered Lines Changed/Added Lines %
satpy/composites/lightning.py 18 34 52.94%
Totals Coverage Status
Change from base Build 10654375136: 96.1%
Covered Lines: 52426
Relevant Lines: 54540

💛 - Coveralls

Copy link
Member

@ameraner ameraner left a comment

Choose a reason for hiding this comment

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

Thanks for this first draft! I left a comment regarding the reference time.

satpy/composites/lightning.py Outdated Show resolved Hide resolved
@ClementLaplace ClementLaplace marked this pull request as ready for review December 6, 2024 09:44
@djhoese djhoese added enhancement code enhancements, features, improvements component:compositors labels Dec 6, 2024
Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

I'm really surprised that our pre-commit/linters are not catching the spacing inconsistencies. I've made some comments on small style things, but also on some bigger things that should be changed. Thanks for getting this going.

On a higher-level discussion, shouldn't this kind of functionality be something implemented in the reader?

Comment on lines +41 to +42
self.name = name
super().__init__(name, prerequisites, optional_prerequisites, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.name = name
super().__init__(name, prerequisites, optional_prerequisites, **kwargs)
super().__init__(name, prerequisites, optional_prerequisites, **kwargs)

Comment on lines +49 to +50
def _normalize_time(self,data:xr.DataArray,attrs:dict)->xr.DataArray:
"""Normalised the time in the range between [end_time,end_time - time_range].
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def _normalize_time(self,data:xr.DataArray,attrs:dict)->xr.DataArray:
"""Normalised the time in the range between [end_time,end_time - time_range].
def _normalize_time(self, data:xr.DataArray,attrs:dict) -> xr.DataArray:
"""Normalize the time in the range between [end_time, end_time - time_range].

I'm not sure why the linter isn't marking the spaces or the docstring first word. Ruff must not be able to do that yet.

Comment on lines +70 to +72
if data.size == 0 :
LOG.error(f"All the flash_age events happened before {begin_time}")
sys.exit(1)
Copy link
Member

Choose a reason for hiding this comment

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

Composites should not be exiting the system. Some exception should be raised or an empty image/composite should be the result.

new_attrs = data.attrs.copy()
self._update_missing_metadata(new_attrs, attrs)
new_attrs = self._redefine_metadata(new_attrs)
return self._normalize_time(data,new_attrs)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return self._normalize_time(data,new_attrs)
return self._normalize_time(data, new_attrs)

dict: atualised attributes
"""
attrs["name"] = self.standard_name
attrs["standard_name"] =self.standard_name
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
attrs["standard_name"] =self.standard_name
attrs["standard_name"] = self.standard_name

# Normalize the time values
normalized_data = (data - begin_time) / (end_time - begin_time)
# Ensure the result is still an xarray.DataArray
return xr.DataArray(normalized_data, dims=data.dims, coords=data.coords,attrs=attrs)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return xr.DataArray(normalized_data, dims=data.dims, coords=data.coords,attrs=attrs)
return xr.DataArray(normalized_data, dims=data.dims, coords=data.coords, attrs=attrs)

# Get the time_range which is in minute
self.time_range = self.attrs["time_range"]
self.standard_name = self.attrs["standard_name"]
self.reference_time = self.attrs["reference_time"]
Copy link
Member

Choose a reason for hiding this comment

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

This is actually the name of the attribute in the DataArray.attrs, right? Could this be renamed reference_time_attr or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:compositors enhancement code enhancements, features, improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants