Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9d6d97a
Allow for the case where no orbit number is present in the incoming m…
Apr 20, 2022
a0eab76
Merge branch 'main' into add-atms-runner
Feb 8, 2023
4a1cd19
First attempts to add support for ATMS SDR processing
Feb 8, 2023
b423729
Add tests to cover the subprocess call
Feb 8, 2023
6587ccd
Add verbosity option
Feb 9, 2023
43a0f58
Remove pdb from code
Feb 9, 2023
9873a17
Fix call options for cspp/atms script
Feb 9, 2023
d41746a
create and send output messages when ATMS processing is ready
Feb 10, 2023
fb12b2a
Add missing stop method
Feb 10, 2023
17c4a48
Add more debug info
Feb 10, 2023
deb3a03
Fix correct orbit number in output messages
Feb 10, 2023
37a2d29
Bugfix, and refactor orbit number estimation
Feb 10, 2023
95060fa
Temporarily fix path without schema and host specification
Feb 10, 2023
dc26f06
Improve logging doing less info and more debug
Apr 6, 2023
517932a
Remove unused (commented out) code
May 2, 2023
5c5b61a
Merge branch 'add-atms-runner' into smhi-atms
May 4, 2023
a29bd84
Add template for atms cspp configuration
May 4, 2023
233f54c
Merge branch 'add-atms-runner' into smhi-atms
May 4, 2023
99ae1bc
Merge branch 'add-option-to-turn-off-lut-updating' into smhi-atms
May 5, 2023
cda5fd5
Merge branch 'main' into add-atms-runner
adybbroe May 22, 2023
c599701
Make anc/lut download flexible so that it is only attempted if script…
Jul 7, 2023
5c214f1
Add support for NOAA-21
Jul 7, 2023
470e316
Fix directory name from one of the three SDR files
Oct 9, 2023
f87b378
Merge branch 'add-atms-runner' of github.com:adybbroe/pytroll-cspp-ru…
Oct 9, 2023
6205e1a
Fix test
Oct 9, 2023
7a4ef14
Merge branch 'add-atms-runner' into smhi-atms
Oct 9, 2023
e9e399d
Add some more debug printouts
Mar 13, 2024
2865433
Skip hostname and scheme in uri - use only the full file path
Mar 13, 2024
2c8afef
Merge branch 'smhi-atms' into add-atms-runner
May 26, 2025
d8f4f5e
Merge branch 'old-setup-with-noaa21-and-flexible-download-mechanism' …
May 26, 2025
a5b7f64
Modernize the version handling using setuptools-scm
May 26, 2025
4a530d3
Fix CI and add pyproject.toml
May 26, 2025
9defb65
Temporarily skip failing asserts
May 26, 2025
76140f8
Roll back coverage ci testing
May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on: [push, pull_request]
on:
- push
- pull_request

jobs:
test:
Expand All @@ -9,11 +11,11 @@ jobs:
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10"]
os: ["ubuntu-latest"]
python-version: ["3.10", "3.11", "3.12"]
experimental: [false]
include:
- python-version: "3.9"
- python-version: "3.12"
os: "ubuntu-latest"
experimental: true

Expand All @@ -25,10 +27,10 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
pytest --cov=cspp_runner cspp_runner/tests --cov-report=xml

- name: Upload unittest coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5
with:
flags: unittests
file: ./coverage.xml
Expand Down
98 changes: 98 additions & 0 deletions bin/atms_dr_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2022, 2023 Pytroll developers

# Author(s):

# Adam Dybbroe <Firstname.Lastname at smhi.se>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Level-1 processing for Direct Readout S-NPP/JPSS ATMS data.

Using the CSPP level-1 processor from the SSEC, Wisconsin, based on the ADL
software from NASA. Listen for pytroll messages of ready RDR files trigger
processing on direct readout RDR data (granules or full swaths).

"""

import argparse
import logging
import os
import sys
import logging.handlers

from cspp_runner.atms_rdr2sdr_runner import AtmsSdrRunner
from cspp_runner.logger import setup_logging

CSPP_SDR_HOME = os.environ.get("CSPP_SDR_HOME", '')

#: Default time format
_DEFAULT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'

#: Default log format
_DEFAULT_LOG_FORMAT = '[%(levelname)s: %(asctime)s : %(name)s] %(message)s'


LOG = logging.getLogger(__name__)


def get_parser():
"""Get parser for commandline-arguments."""
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config-file",
required=True,
dest="config_file",
type=str,
default=None,
help="The file containing configuration parameters.")
parser.add_argument("-l", "--log-config",
help="Log config file to use instead of the standard logging.")
parser.add_argument("-v", "--verbose", dest="verbosity", action="count", default=0,
help="Verbosity (between 1 and 2 occurrences with more leading to more "
"verbose logging). WARN=0, INFO=1, "
"DEBUG=2. This is overridden by the log config file if specified.")
return parser


def parse_args():
"""Parse command-line arguments."""
parser = get_parser()
return parser.parse_args()


def main():
"""Start the CSPP ATMS runner."""
cmd_args = parse_args()
print("Read config from", cmd_args.config_file)

setup_logging(cmd_args)

try:
atms = AtmsSdrRunner(cmd_args.config_file)
except Exception as err:
LOG.error('ATMS RDR to SDR processing crashed: %s', str(err))
sys.exit(1)
try:
atms.start()
atms.join()
except KeyboardInterrupt:
LOG.debug("Interrupting")
finally:
atms.close()


if __name__ == "__main__":
main()
33 changes: 18 additions & 15 deletions cspp_runner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2014 - 2020 Pytroll

# Author(s):

# Adam.Dybbroe <adam.dybbroe@smhi.se>
# Lars Ørum Rasmussen <ras@dmi.dk>
# Copyright (c) 2014 - 2025 Pytroll developers

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -27,12 +22,15 @@
from datetime import datetime, timedelta
import re
import logging
from pkg_resources import get_distribution, DistributionNotFound

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
from cspp_runner.version import version as __version__ # noqa
except ModuleNotFoundError:
raise ModuleNotFoundError(

Check warning on line 29 in cspp_runner/__init__.py

View check run for this annotation

Codecov / codecov/patch

cspp_runner/__init__.py#L28-L29

Added lines #L28 - L29 were not covered by tests
"No module named cspp_runner.version. This could mean "
"you didn't install 'cspp_runner' properly. Try reinstalling ('pip "
"install cspp_runner').")


LOG = logging.getLogger(__name__)

Expand All @@ -41,18 +39,22 @@


class NPPStamp(object):
"""A data structure for a NPP/JPSS VIIRS SDR file stamp.

""" A NPP stamp is:
A NPP stamp is:
<platform>_d<start_date>_t<start_time>_e<end_time>_b<orbit_number>

"""

def __init__(self, platform, start_time, end_time, orbit_number):
"""Initialize the class."""
self.platform = platform
self.start_time = start_time
self.end_time = end_time
self.orbit_number = orbit_number

def __str__(self):
"""Documentation."""
date = self.start_time.strftime('%Y%m%d')
start = (self.start_time.strftime('%H%M%S') +
str(self.start_time.microsecond / 100000)[0])
Expand All @@ -63,7 +65,8 @@


def get_npp_stamp(filename):
"""A unique stamp for a granule.
"""Get a unique stamp for a granule.

<name>_d<date>_t<start-time>_e<end-time>_b<orbit_number>
"""
match = _RE_NPP_STAMP.match(os.path.basename(filename))
Expand Down Expand Up @@ -108,7 +111,8 @@


def is_same_granule(filename1, filename2, sec_tolerance):
"""
"""Check if an SDR file is a granule.

Take two SDR/RDR files and check their observation time from the filename
and determine if they belong to the same granule. Small deviations can
happen between RDR files and corresponding SDR files.
Expand All @@ -118,7 +122,6 @@
'SVM11_npp_d20180121_t0903382_e0905024_b32305_c20180121091145126446_cspp_dev.h5'

"""

t1_ = get_datetime_from_filename(filename1)
t2_ = get_datetime_from_filename(filename2)
delta_t = abs(t1_ - t2_)
Expand Down
Loading
Loading