-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # level1c4pps/__init__.py
- Loading branch information
Showing
40 changed files
with
384 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
build | ||
dist | ||
*py~ | ||
*pyc | ||
*~ | ||
*.egg* | ||
*.egg* | ||
*#* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
@@ -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='?', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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', | ||
|
@@ -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): | ||
|
@@ -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: | ||
|
@@ -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__ | ||
|
@@ -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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""" | ||
|
||
|
@@ -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'} | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.