Skip to content

Commit

Permalink
Merge branch 'main' into isccpg_ng
Browse files Browse the repository at this point in the history
# Conflicts:
#	level1c4pps/__init__.py
  • Loading branch information
ninahakansson committed Dec 17, 2024
2 parents 737bd75 + f1d4a07 commit 852aa41
Show file tree
Hide file tree
Showing 40 changed files with 384 additions and 339 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Describe what your PR does, and why -->

- [ ] Closes #xxxx <!-- remove if there is no corresponding issue, which should only be the case for minor changes -->
- [ ] Closes #xxxx <!-- remove if there is no corresponding issue
- [ ] Tests added <!-- for all bug fixes or enhancements -->
- [ ] Tests passed: Passes ``pytest level1c4pps`` <!-- for all non-documentation changes) -->
- [ ] Passes ``flake8`` <!-- remove if you did not edit any Python files -->
- [ ] Fully documented <!-- remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later -->
- [ ] Add your name to `AUTHORS.md` if not there already
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
python-version: ["3.9", "3.11", "3.12"]
experimental: [false]
include:
- python-version: "3.12"
- python-version: "3.13"
os: "ubuntu-latest"
experimental: true

Expand All @@ -28,15 +28,15 @@ jobs:
uses: actions/checkout@v3

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
python-version: ${{ matrix.python-version }}
environment-file: continuous_integration/environment.yaml
activate-environment: test-environment
auto-update-conda: true
channels: conda-forge
conda-remove-defaults: true
channel-priority: strict

- name: Install unstable dependencies
if: matrix.experimental == true
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
build
dist
*py~
*pyc
*~
*.egg*
*.egg*
*#*
12 changes: 12 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Project Contributors

- [Nina Håkansson] (https://github.com/ninahakansson)
- [Bengt Rydberg] (BengtRydberg)](https://github.com/BengtRydberg)
- [Sara Hörnquist] (shornqui)](https://github.com/shornqui)
- [Inderpreet Kaur] (https://github.com/ikaur17)
- [Salomon Eliasson] (https://github.com/salomoneliassonSMHI)
- [Erik Johansson] (https://github.com/smhi-erik)
- [Stephan Finkensieper] (https://github.com/sfinkens)
- [Adam Dybbroe (adybbroe)] (https://github.com/adybbroe)
- [Martin Raspaud (mraspaud)] (https://github.com/mraspaud)
- [Panu Lahtinen (pnuu)] (https://github.com/pnuu)
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## Version <0.2.35> (2024/12/16)

### Issues Closed

* [Issue 94](https://github.com/foua-pps/level1c4pps/issues/94) - VGAC sun-earth distance correction attribute is set wrong ([PR 102](https://github.com/foua-pps/level1c4pps/pull/102) by [@ninahakansson](https://github.com/ninahakansson))
* [Issue 93](https://github.com/foua-pps/level1c4pps/issues/93) - VGAC time unit is in microseconds not milliseconds ([PR 96](https://github.com/foua-pps/level1c4pps/pull/96) by [@BengtRydberg](https://github.com/BengtRydberg))
* [Issue 79](https://github.com/foua-pps/level1c4pps/issues/79) - Satpy doesn't support Python 3.8 anymore

In this release 3 issues were closed.

### Pull Requests Merged

* [PR 102](https://github.com/foua-pps/level1c4pps/pull/102) - Fix VGAC sun earth distance applied attribute, by [@ninahakansson](https://github.com/ninahakansson) ([94](https://github.com/foua-pps/level1c4pps/issues/94))
* [PR 100](https://github.com/foua-pps/level1c4pps/pull/100) - Sbaf n nv4, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)
* [PR 99](https://github.com/foua-pps/level1c4pps/pull/99) - Add fix for sun_earth_distance_correction_factor, by [@ninahakansson](https://github.com/ninahakansson)
* [PR 97](https://github.com/foua-pps/level1c4pps/pull/97) - Sbaf nn, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)
* [PR 96](https://github.com/foua-pps/level1c4pps/pull/96) - vgac time units, by [@BengtRydberg](https://github.com/BengtRydberg) ([93](https://github.com/foua-pps/level1c4pps/issues/93))
* [PR 95](https://github.com/foua-pps/level1c4pps/pull/95) - vgac cli bugfix, by [@BengtRydberg](https://github.com/BengtRydberg)
* [PR 92](https://github.com/foua-pps/level1c4pps/pull/92) - removed check for pygac and numpy2.0 gac2pps_lib.py, by [@ikaur17](https://github.com/ikaur17)
* [PR 91](https://github.com/foua-pps/level1c4pps/pull/91) - adding support for handling mersi3 data, by [@BengtRydberg](https://github.com/BengtRydberg)
* [PR 90](https://github.com/foua-pps/level1c4pps/pull/90) - Adding v3 SBAFs, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)

In this release 9 pull requests were closed.

## Version <0.2.34> (2024/08/29)

### Issues Closed
Expand Down
5 changes: 0 additions & 5 deletions bin/avhrr2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert AVHRR level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
8 changes: 1 addition & 7 deletions bin/eumgacfdr2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>


"""Script to make EUMETSAT GAC level1c in PPS-format with pytroll."""

Expand Down Expand Up @@ -58,7 +52,7 @@
required=False, default=99999,
help="Orbit number (default is 99999).")
options = parser.parse_args()
process_one_file(options.file, options.out_dir, start_line=options.start_line,
process_one_file(options.file, options.out_dir, start_line=options.start_line,
end_line=options.end_line, engine=options.nc_engine,
remove_broken=not options.no_remove_bad,
orbit_n=options.orbit_number)
6 changes: 0 additions & 6 deletions bin/gac2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>


"""Script to make seviri level1c in PPS-format with pytroll."""

Expand Down
5 changes: 0 additions & 5 deletions bin/mersi2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert MERSI-2 level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
5 changes: 0 additions & 5 deletions bin/metimage2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert METIMAGE level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
5 changes: 0 additions & 5 deletions bin/modis2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert MODIS level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
10 changes: 0 additions & 10 deletions bin/seviri2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>
# Stephan Finkensieper <[email protected]>

# This program was developed by CMSAF to be used for the processing of
# CLAAS3.
Expand Down Expand Up @@ -56,16 +50,12 @@
help="Engine for saving netcdf files netcdf4 or h5netcdf (default).")
parser.add_argument('--use-nominal-time-in-filename', action='store_true',
help='Use nominal scan timestamps in output filename.')
parser.add_argument('--no-sun-earth-distance-correction',
action='store_true',
help='Do not apply sun earth distance correction.')
options = parser.parse_args()
process_one_scan(
options.files,
out_path=options.out_dir,
rotate=not options.no_rotation,
engine=options.nc_engine,
use_nominal_time_in_filename=options.use_nominal_time_in_filename,
apply_sun_earth_distance_correction=not options.no_sun_earth_distance_correction,
save_azimuth_angles=options.azimuth_angles,
)
5 changes: 0 additions & 5 deletions bin/slstr2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert SLSTR level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
6 changes: 0 additions & 6 deletions bin/vgac2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>
# Salomon.Eliasson <[email protected]>

"""Script to convert VIIRS level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand Down
7 changes: 1 addition & 6 deletions bin/viirs2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Script to convert VIIRS level-1 to PPS level-1c format using Pytroll/Satpy."""

Expand All @@ -41,7 +36,7 @@
help="Output directory where to store the level1c file")
parser.add_argument('--iband', action='store_true',
help="Iband resolution include I01-I03, M15-M16 and optional M09, M14")
parser.add_argument('--reader', type=str, nargs='?',
parser.add_argument('--reader', type=str, nargs='?',
required=False, default="viirs_sdr",
help="VIIRS reader default: viirs_sdr")
parser.add_argument('-ne', '--nc_engine', type=str, nargs='?',
Expand Down
6 changes: 1 addition & 5 deletions continuous_integration/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ name: test-environment
channels:
- conda-forge
dependencies:
- tensorflow
- scikit-learn
- sphinx
- scipy
- h5py
- python-geotiepoints
- matplotlib
- mock
- numpy<2.0.0
- numpy
- satpy>0.41.1
- pyspectral
- h5netcdf
Expand All @@ -21,4 +18,3 @@ dependencies:
- pip:
- trollsift
- pygac
- git+https://github.com/foua-pps/sbafs_ann@main
31 changes: 22 additions & 9 deletions level1c4pps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Adam.Dybbroe <[email protected]>
# Nina Hakansson <[email protected]>

"""Package Initializer for level1c4pps."""
from importlib.metadata import version
Expand Down Expand Up @@ -184,12 +180,12 @@ def convert_angles(scene, delete_azimuth=False):
'sunazimuth': np.array([-18000, 18000], dtype='int16'),
'satazimuth': np.array([-18000, 18000], dtype='int16'),
},
'mersi_file_key': {
'mersi_file_key': {
'sunzenith': 'Geolocation/SolarZenithAngle',
'satzenith': 'Geolocation/SensorZenithAngle',
'azimuthdiff': 'Geolocation/SensorSolarAzimuthDifference',
},
'standard_name': {
'standard_name': {
'sunzenith': 'solar_zenith_angle',
'satzenith': 'sensor_zenith_angle', # platform in ppsv2018
'azimuthdiff': 'absolute_angle_of_rotation_from_solar_azimuth_to_platform_azimuth',
Expand All @@ -211,12 +207,12 @@ def convert_angles(scene, delete_azimuth=False):
'standard_name': "longitude",
'units': 'degrees_east',
'valid_range': np.array([-180, 180], dtype='float32')}
}
}


def make_azidiff_angle(sata, suna, divisor=360):
"""Calculate azimuth difference angle."""
daz = abs(sata-suna)
daz = abs(sata - suna)
half_divisor = divisor / 2.0
daz = daz % divisor
if isinstance(daz, np.ndarray):
Expand Down Expand Up @@ -369,6 +365,22 @@ def adjust_lons_to_valid_range(scene):
scene['lon'].values = centered_modulus(scene['lon'].values)


def fix_sun_earth_distance_correction_factor(scene, band, start_time):
from pyorbital.astronomy import sun_earth_distance_correction
date_control = np.datetime64("2019-01-01T00:00:00")
sun_earth_distance_20190409 = sun_earth_distance_correction(date_control)
sun_earth_distance = sun_earth_distance_correction(start_time)
if (np.abs(sun_earth_distance_20190409 - 0.9833280675966011) < 0.00001 and
np.abs(sun_earth_distance - scene[band].attrs['sun_earth_distance_correction_factor']) < 0.00001):
logger.info("The sun earth distance correction attribute contain the sun earth distance, not the square.")
logger.info("Updating and adding sun earth distance correction attributes.")
current_factor = scene[band].attrs['sun_earth_distance_correction_factor']
scene[band].attrs['satpy_sun_earth_distance_correction_factor'] = current_factor
scene[band].attrs['pps_sun_earth_distance_correction_factor'] = sun_earth_distance * sun_earth_distance
scene[band].attrs['sun_earth_distance'] = sun_earth_distance
scene[band].attrs['sun_earth_distance_correction_factor'] = sun_earth_distance * sun_earth_distance


def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BANDS, irch, orbit_n=0):
"""Add some default values for band attributes."""
# Set some header attributes:
Expand Down Expand Up @@ -398,7 +410,7 @@ def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BAND
sensor_name = (fix_too_great_attributes(sensor_name)).upper()
scene.attrs['sensor'] = sensor_name.upper()
scene.attrs['instrument'] = sensor_name.upper()
nowutc = datetime.utcnow()
nowutc = datetime.now(timezone.utc)
scene.attrs['orbit_number'] = int(orbit_n)
scene.attrs['date_created'] = nowutc.strftime("%Y-%m-%dT%H:%M:%SZ")
scene.attrs['version_level1c4pps_satpy'] = satpy.__version__
Expand All @@ -422,6 +434,7 @@ def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BAND
else:
# Assume factor applied if available as attribute.
scene[band].attrs['sun_earth_distance_correction_applied'] = 'True'
fix_sun_earth_distance_correction_factor(scene, band, irch.attrs['start_time'])
if 'wavelength' in scene[band].attrs:
scene[band].attrs['wavelength'] = scene[band].attrs['wavelength'][0:3]
scene[band].attrs['sun_zenith_angle_correction_applied'] = 'False'
Expand Down
13 changes: 4 additions & 9 deletions level1c4pps/avhrr2pps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# Author(s):

# Martin Raspaud <[email protected]>
# Nina Hakansson <[email protected]>
# Adam.Dybbroe <[email protected]>

"""Functions to convert AVHRR AAPP or EPS l1b data to a NWCSAF/PPS level-1c formatet netCDF/CF file."""

Expand Down Expand Up @@ -50,9 +45,9 @@

REFL_BANDS = ['1', '2', '3a']

PPS_TAGNAMES = {'1': 'ch_r06',
'2': 'ch_r09',
'3a': 'ch_r16',
PPS_TAGNAMES = {'1': 'ch_r06',
'2': 'ch_r09',
'3a': 'ch_r16',
'3b': 'ch_tb37',
'4': 'ch_tb11',
'5': 'ch_tb12'}
Expand Down Expand Up @@ -133,5 +128,5 @@ def process_one_scene(scene_files, out_path, engine='h5netcdf', orbit_n=0):
encoding=get_encoding_avhrr(scn_))
print("Saved file {:s} after {:3.1f} seconds".format(
os.path.basename(filename),
time.time()-tic))
time.time() - tic))
return filename
4 changes: 0 additions & 4 deletions level1c4pps/calibration_coefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#
# You should have received a copy of the GNU General Public License
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
# Author(s):

# Nina.Hakansson

"""Module with calibration coefficients for SEVIRI."""

Expand Down
Loading

0 comments on commit 852aa41

Please sign in to comment.