Skip to content

Commit 852aa41

Browse files
committed
Merge branch 'main' into isccpg_ng
# Conflicts: # level1c4pps/__init__.py
2 parents 737bd75 + f1d4a07 commit 852aa41

40 files changed

+384
-339
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Describe what your PR does, and why -->
22

3-
- [ ] Closes #xxxx <!-- remove if there is no corresponding issue, which should only be the case for minor changes -->
3+
- [ ] Closes #xxxx <!-- remove if there is no corresponding issue
44
- [ ] Tests added <!-- for all bug fixes or enhancements -->
55
- [ ] Tests passed: Passes ``pytest level1c4pps`` <!-- for all non-documentation changes) -->
66
- [ ] Passes ``flake8`` <!-- remove if you did not edit any Python files -->
7-
- [ ] 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 -->
7+
- [ ] Add your name to `AUTHORS.md` if not there already

.github/workflows/ci.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
python-version: ["3.9", "3.11", "3.12"]
1414
experimental: [false]
1515
include:
16-
- python-version: "3.12"
16+
- python-version: "3.13"
1717
os: "ubuntu-latest"
1818
experimental: true
1919

@@ -28,15 +28,15 @@ jobs:
2828
uses: actions/checkout@v3
2929

3030
- name: Setup Conda Environment
31-
uses: conda-incubator/setup-miniconda@v2
31+
uses: conda-incubator/setup-miniconda@v3
3232
with:
33-
miniforge-variant: Mambaforge
3433
miniforge-version: latest
35-
use-mamba: true
3634
python-version: ${{ matrix.python-version }}
3735
environment-file: continuous_integration/environment.yaml
3836
activate-environment: test-environment
39-
auto-update-conda: true
37+
channels: conda-forge
38+
conda-remove-defaults: true
39+
channel-priority: strict
4040

4141
- name: Install unstable dependencies
4242
if: matrix.experimental == true

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
build
2+
dist
23
*py~
34
*pyc
45
*~
5-
*.egg*
6+
*.egg*
7+
*#*

AUTHORS.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Project Contributors
2+
3+
- [Nina Håkansson] (https://github.com/ninahakansson)
4+
- [Bengt Rydberg] (BengtRydberg)](https://github.com/BengtRydberg)
5+
- [Sara Hörnquist] (shornqui)](https://github.com/shornqui)
6+
- [Inderpreet Kaur] (https://github.com/ikaur17)
7+
- [Salomon Eliasson] (https://github.com/salomoneliassonSMHI)
8+
- [Erik Johansson] (https://github.com/smhi-erik)
9+
- [Stephan Finkensieper] (https://github.com/sfinkens)
10+
- [Adam Dybbroe (adybbroe)] (https://github.com/adybbroe)
11+
- [Martin Raspaud (mraspaud)] (https://github.com/mraspaud)
12+
- [Panu Lahtinen (pnuu)] (https://github.com/pnuu)

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## Version <0.2.35> (2024/12/16)
2+
3+
### Issues Closed
4+
5+
* [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))
6+
* [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))
7+
* [Issue 79](https://github.com/foua-pps/level1c4pps/issues/79) - Satpy doesn't support Python 3.8 anymore
8+
9+
In this release 3 issues were closed.
10+
11+
### Pull Requests Merged
12+
13+
* [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))
14+
* [PR 100](https://github.com/foua-pps/level1c4pps/pull/100) - Sbaf n nv4, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)
15+
* [PR 99](https://github.com/foua-pps/level1c4pps/pull/99) - Add fix for sun_earth_distance_correction_factor, by [@ninahakansson](https://github.com/ninahakansson)
16+
* [PR 97](https://github.com/foua-pps/level1c4pps/pull/97) - Sbaf nn, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)
17+
* [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))
18+
* [PR 95](https://github.com/foua-pps/level1c4pps/pull/95) - vgac cli bugfix, by [@BengtRydberg](https://github.com/BengtRydberg)
19+
* [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)
20+
* [PR 91](https://github.com/foua-pps/level1c4pps/pull/91) - adding support for handling mersi3 data, by [@BengtRydberg](https://github.com/BengtRydberg)
21+
* [PR 90](https://github.com/foua-pps/level1c4pps/pull/90) - Adding v3 SBAFs, by [@salomoneliassonSMHI](https://github.com/salomoneliassonSMHI)
22+
23+
In this release 9 pull requests were closed.
24+
125
## Version <0.2.34> (2024/08/29)
226

327
### Issues Closed

bin/avhrr2pps.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

bin/eumgacfdr2pps.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
24-
2519

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

@@ -58,7 +52,7 @@
5852
required=False, default=99999,
5953
help="Orbit number (default is 99999).")
6054
options = parser.parse_args()
61-
process_one_file(options.file, options.out_dir, start_line=options.start_line,
55+
process_one_file(options.file, options.out_dir, start_line=options.start_line,
6256
end_line=options.end_line, engine=options.nc_engine,
6357
remove_broken=not options.no_remove_bad,
6458
orbit_n=options.orbit_number)

bin/gac2pps.py

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
24-
2519

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

bin/mersi2pps.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

bin/metimage2pps.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

bin/modis2pps.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

bin/seviri2pps.py

-10
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
24-
# Stephan Finkensieper <stephan.finkensieper@dwd.de>
2519

2620
# This program was developed by CMSAF to be used for the processing of
2721
# CLAAS3.
@@ -56,16 +50,12 @@
5650
help="Engine for saving netcdf files netcdf4 or h5netcdf (default).")
5751
parser.add_argument('--use-nominal-time-in-filename', action='store_true',
5852
help='Use nominal scan timestamps in output filename.')
59-
parser.add_argument('--no-sun-earth-distance-correction',
60-
action='store_true',
61-
help='Do not apply sun earth distance correction.')
6253
options = parser.parse_args()
6354
process_one_scan(
6455
options.files,
6556
out_path=options.out_dir,
6657
rotate=not options.no_rotation,
6758
engine=options.nc_engine,
6859
use_nominal_time_in_filename=options.use_nominal_time_in_filename,
69-
apply_sun_earth_distance_correction=not options.no_sun_earth_distance_correction,
7060
save_azimuth_angles=options.azimuth_angles,
7161
)

bin/slstr2pps.py

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

bin/vgac2pps.py

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
24-
# Salomon.Eliasson <salomon.eliasson@smhi.se>
2519

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

bin/viirs2pps.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

@@ -41,7 +36,7 @@
4136
help="Output directory where to store the level1c file")
4237
parser.add_argument('--iband', action='store_true',
4338
help="Iband resolution include I01-I03, M15-M16 and optional M09, M14")
44-
parser.add_argument('--reader', type=str, nargs='?',
39+
parser.add_argument('--reader', type=str, nargs='?',
4540
required=False, default="viirs_sdr",
4641
help="VIIRS reader default: viirs_sdr")
4742
parser.add_argument('-ne', '--nc_engine', type=str, nargs='?',

continuous_integration/environment.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ name: test-environment
22
channels:
33
- conda-forge
44
dependencies:
5-
- tensorflow
6-
- scikit-learn
75
- sphinx
86
- scipy
97
- h5py
108
- python-geotiepoints
11-
- matplotlib
129
- mock
13-
- numpy<2.0.0
10+
- numpy
1411
- satpy>0.41.1
1512
- pyspectral
1613
- h5netcdf
@@ -21,4 +18,3 @@ dependencies:
2118
- pip:
2219
- trollsift
2320
- pygac
24-
- git+https://github.com/foua-pps/sbafs_ann@main

level1c4pps/__init__.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
2319

2420
"""Package Initializer for level1c4pps."""
2521
from importlib.metadata import version
@@ -184,12 +180,12 @@ def convert_angles(scene, delete_azimuth=False):
184180
'sunazimuth': np.array([-18000, 18000], dtype='int16'),
185181
'satazimuth': np.array([-18000, 18000], dtype='int16'),
186182
},
187-
'mersi_file_key': {
183+
'mersi_file_key': {
188184
'sunzenith': 'Geolocation/SolarZenithAngle',
189185
'satzenith': 'Geolocation/SensorZenithAngle',
190186
'azimuthdiff': 'Geolocation/SensorSolarAzimuthDifference',
191187
},
192-
'standard_name': {
188+
'standard_name': {
193189
'sunzenith': 'solar_zenith_angle',
194190
'satzenith': 'sensor_zenith_angle', # platform in ppsv2018
195191
'azimuthdiff': 'absolute_angle_of_rotation_from_solar_azimuth_to_platform_azimuth',
@@ -211,12 +207,12 @@ def convert_angles(scene, delete_azimuth=False):
211207
'standard_name': "longitude",
212208
'units': 'degrees_east',
213209
'valid_range': np.array([-180, 180], dtype='float32')}
214-
}
210+
}
215211

216212

217213
def make_azidiff_angle(sata, suna, divisor=360):
218214
"""Calculate azimuth difference angle."""
219-
daz = abs(sata-suna)
215+
daz = abs(sata - suna)
220216
half_divisor = divisor / 2.0
221217
daz = daz % divisor
222218
if isinstance(daz, np.ndarray):
@@ -369,6 +365,22 @@ def adjust_lons_to_valid_range(scene):
369365
scene['lon'].values = centered_modulus(scene['lon'].values)
370366

371367

368+
def fix_sun_earth_distance_correction_factor(scene, band, start_time):
369+
from pyorbital.astronomy import sun_earth_distance_correction
370+
date_control = np.datetime64("2019-01-01T00:00:00")
371+
sun_earth_distance_20190409 = sun_earth_distance_correction(date_control)
372+
sun_earth_distance = sun_earth_distance_correction(start_time)
373+
if (np.abs(sun_earth_distance_20190409 - 0.9833280675966011) < 0.00001 and
374+
np.abs(sun_earth_distance - scene[band].attrs['sun_earth_distance_correction_factor']) < 0.00001):
375+
logger.info("The sun earth distance correction attribute contain the sun earth distance, not the square.")
376+
logger.info("Updating and adding sun earth distance correction attributes.")
377+
current_factor = scene[band].attrs['sun_earth_distance_correction_factor']
378+
scene[band].attrs['satpy_sun_earth_distance_correction_factor'] = current_factor
379+
scene[band].attrs['pps_sun_earth_distance_correction_factor'] = sun_earth_distance * sun_earth_distance
380+
scene[band].attrs['sun_earth_distance'] = sun_earth_distance
381+
scene[band].attrs['sun_earth_distance_correction_factor'] = sun_earth_distance * sun_earth_distance
382+
383+
372384
def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BANDS, irch, orbit_n=0):
373385
"""Add some default values for band attributes."""
374386
# Set some header attributes:
@@ -398,7 +410,7 @@ def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BAND
398410
sensor_name = (fix_too_great_attributes(sensor_name)).upper()
399411
scene.attrs['sensor'] = sensor_name.upper()
400412
scene.attrs['instrument'] = sensor_name.upper()
401-
nowutc = datetime.utcnow()
413+
nowutc = datetime.now(timezone.utc)
402414
scene.attrs['orbit_number'] = int(orbit_n)
403415
scene.attrs['date_created'] = nowutc.strftime("%Y-%m-%dT%H:%M:%SZ")
404416
scene.attrs['version_level1c4pps_satpy'] = satpy.__version__
@@ -422,6 +434,7 @@ def set_header_and_band_attrs_defaults(scene, BANDNAMES, PPS_TAGNAMES, REFL_BAND
422434
else:
423435
# Assume factor applied if available as attribute.
424436
scene[band].attrs['sun_earth_distance_correction_applied'] = 'True'
437+
fix_sun_earth_distance_correction_factor(scene, band, irch.attrs['start_time'])
425438
if 'wavelength' in scene[band].attrs:
426439
scene[band].attrs['wavelength'] = scene[band].attrs['wavelength'][0:3]
427440
scene[band].attrs['sun_zenith_angle_correction_applied'] = 'False'

level1c4pps/avhrr2pps_lib.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# Author(s):
20-
21-
# Martin Raspaud <martin.raspaud@smhi.se>
22-
# Nina Hakansson <nina.hakansson@smhi.se>
23-
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2419

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

@@ -50,9 +45,9 @@
5045

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

53-
PPS_TAGNAMES = {'1': 'ch_r06',
54-
'2': 'ch_r09',
55-
'3a': 'ch_r16',
48+
PPS_TAGNAMES = {'1': 'ch_r06',
49+
'2': 'ch_r09',
50+
'3a': 'ch_r16',
5651
'3b': 'ch_tb37',
5752
'4': 'ch_tb11',
5853
'5': 'ch_tb12'}
@@ -133,5 +128,5 @@ def process_one_scene(scene_files, out_path, engine='h5netcdf', orbit_n=0):
133128
encoding=get_encoding_avhrr(scn_))
134129
print("Saved file {:s} after {:3.1f} seconds".format(
135130
os.path.basename(filename),
136-
time.time()-tic))
131+
time.time() - tic))
137132
return filename

level1c4pps/calibration_coefs.py

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#
1717
# You should have received a copy of the GNU General Public License
1818
# along with level1c4pps. If not, see <http://www.gnu.org/licenses/>.
19-
# -*- coding: utf-8 -*-
20-
# Author(s):
21-
22-
# Nina.Hakansson
2319

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

0 commit comments

Comments
 (0)