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

STY: updates to export options #1117

Merged
merged 12 commits into from
May 17, 2023
Merged

STY: updates to export options #1117

merged 12 commits into from
May 17, 2023

Conversation

jklenzing
Copy link
Member

Description

Updates the pysat export options for operational instruments. Better integration with jklenzing/ops_reach#15

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

via updated unit tests

pytest pysat/tests/test_utils_io.py::TestLoadNetCDF::test_basic_write_and_read_netcdf_export_pysat_info

Test Configuration:

  • Operating system: Mac 13.3.1
  • Version number: Python 3.10.8

Checklist:

  • Make sure you are merging into the develop (not main) branch
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • Add a note to CHANGELOG.md, summarizing the changes

If this is a release PR, replace the first item of the above checklist with the release
checklist on the wiki: https://github.com/pysat/pysat/wiki/Checklist-for-Release

CHANGELOG.md Outdated Show resolved Hide resolved
test_requirements.txt Outdated Show resolved Hide resolved
@jklenzing jklenzing marked this pull request as ready for review April 25, 2023 23:09
@@ -1725,7 +1725,8 @@ def inst_to_netcdf(inst, fname, base_instrument=None, epoch_name=None,
# Remove any attributes with the names below. pysat is responsible
# for including them in the file.
pysat_items = ['Date_End', 'Date_Start', 'File', 'File_Date',
'Generation_Date', 'Logical_File_ID']
'Generation_Date', 'Logical_File_ID', 'acknowledgements',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wanted to bring this question into the pull request.
Do these items still need to be popped?
We're assigning all of them in the following lines, so maybe they can be left un-popped.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't tried swapping these out. Not sure if this is a remnant from python 2.7. acknowledgements and references have to be popped for compatibility with the operational bits below.

@jklenzing
Copy link
Member Author

@JonathonMSmith, I'd like to get this one into the RC if possible. What's the best path forward to address the issues above?

@jklenzing jklenzing requested a review from aburrell May 8, 2023 14:38
@aburrell
Copy link
Member

aburrell commented May 8, 2023

Are you sure you want to pull this into the RC and re-request all reviews?

@jklenzing
Copy link
Member Author

This is needed for the operational data stuff for REACH

@JonathonMSmith
Copy link
Collaborator

I don't know the best path forward. I removed the lines where these variables are popped in my local version of the RC branch and all of the unit tests pass, but I don't know if that's enough. I don't see how any of these attributes could get through without being overwritten because the the assignments on lines 1735-1756 are not conditional, the appear to always occur.

@jklenzing
Copy link
Member Author

My thought is open an issue. We probably want to test this more with existing operational software before removing this code.

@jklenzing
Copy link
Member Author

I don't know the best path forward. I removed the lines where these variables are popped in my local version of the RC branch and all of the unit tests pass, but I don't know if that's enough. I don't see how any of these attributes could get through without being overwritten because the the assignments on lines 1735-1756 are not conditional, the appear to always occur.

I've added #1122 for the next version. We can make a decision then. The rest of this still needs a review.

@jklenzing jklenzing removed the request for review from aburrell May 9, 2023 18:32
Copy link
Collaborator

@JonathonMSmith JonathonMSmith left a comment

Choose a reason for hiding this comment

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

why do references and acknowledgments need to be dropped from the attribute dict unless export_pysat_info is true?

@jklenzing
Copy link
Member Author

jklenzing commented May 9, 2023

why do references and acknowledgments need to be dropped from the attribute dict unless export_pysat_info is true?

I can't actually find where this happens in the code, but acknowledgements and references are transferred to the meta header info while the other pysat properties are not. If I don't pop these, then the unit test will fail since they still exist.

I think it's because these are set during the init function. If I try this on pysat_testing, the other global attrs set here get added automatically.

import pysat
import xarray as xr

test = pysat.Instrument('pysat', 'testing', use_header=True)
test.load(2009, 1)
test.to_netcdf4('./test.nc', export_pysat_info=False)
a = xr.open_dataset('test.nc')
In [13]: a.attrs
Out[13]: 
{'new_thing': 1,
 'test_clean_kwarg': '',
 'test_init_kwarg': '',
 'test_preprocess_kwarg': '',
 'pysat_version': '3.1.0.1rc1',
 'Conventions': 'pysat-simplified SPDF ISTP/IACG for NetCDF',
 'Text_Supplement': '',
 'Date_End': 'Thu, 01 Jan 2009,  2009-01-01T23:59:59.000 UTC',
 'Date_Start': 'Thu, 01 Jan 2009,  2009-01-01T00:00:00.000 UTC',
 'File': ['.', 'test.nc'],
 'File_Date': 'Thu, 01 Jan 2009,  2009-01-01T23:59:59.000 UTC',
 'Generation_Date': '20230509',
 'Logical_File_ID': 'test'}

@jklenzing jklenzing merged commit 6ec0c46 into rc_3_1_0 May 17, 2023
14 checks passed
@jklenzing jklenzing deleted the sty/spdf branch May 17, 2023 22:01
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