Skip to content

Commit

Permalink
Merge pull request #103 from ninahakansson/fix_ci_and_authors
Browse files Browse the repository at this point in the history
Fix github tests
  • Loading branch information
ninahakansson authored Dec 17, 2024
2 parents 59c69f0 + 177aed1 commit f1d4a07
Show file tree
Hide file tree
Showing 39 changed files with 184 additions and 299 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)
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
6 changes: 0 additions & 6 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
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
21 changes: 9 additions & 12 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 @@ -368,20 +364,21 @@ def adjust_lons_to_valid_range(scene):
# scene['lon'] = centered_modulus(scene['lon']) # makes lon loose attrs satpy 0.24.0
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):
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['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
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):
Expand Down Expand Up @@ -413,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 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
7 changes: 1 addition & 6 deletions level1c4pps/eumgacfdr2pps_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]>

"""Utilities to convert AVHRR GAC formattet data to PPS level-1c format."""

Expand Down Expand Up @@ -249,5 +244,5 @@ def process_one_file(eumgacfdr_file, out_path='.', reader_kwargs=None,

logger.info("Saved file {:s} after {:3.1f} seconds".format(
os.path.basename(filename),
time.time()-tic))
time.time() - tic))
return filename
9 changes: 1 addition & 8 deletions level1c4pps/gac2pps_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]>

"""Utilities to convert AVHRR GAC formattet data to PPS level-1c format."""

Expand All @@ -39,11 +34,9 @@
get_header_attrs, convert_angles)
import logging

from packaging.version import Version
logger = logging.getLogger('gac2pps')



BANDNAMES = ['1', '2', '3', '3a', '3b', '4', '5']

REFL_BANDS = ['1', '2', '3a']
Expand Down Expand Up @@ -171,5 +164,5 @@ def process_one_file(gac_file, out_path='.', reader_kwargs=None, engine='h5netcd

print("Saved file {:s} after {:3.1f} seconds".format(
os.path.basename(filename),
time.time()-tic))
time.time() - tic))
return filename
Loading

0 comments on commit f1d4a07

Please sign in to comment.