Skip to content

Commit

Permalink
Merge pull request pytroll#3 from adybbroe/publish-different-fileform…
Browse files Browse the repository at this point in the history
…ats-separately

Publish different fileformats separately
  • Loading branch information
adybbroe committed Aug 20, 2020
2 parents bc9db5c + ad2ef0b commit af09f4d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 65 deletions.
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
63 changes: 34 additions & 29 deletions bin/viirs_af_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2019 Pytroll
# Copyright (c) 2019, 2020 Pytroll

# Author(s):

Expand Down Expand Up @@ -172,7 +172,7 @@ def spawn_cspp(sdrfiles, service):


def publish_af(publisher, result_files, mda, **kwargs):
"""Publish the messages that SDR files are ready
"""Publish the messages that VIIRS AF EDR files are ready
"""
if not result_files:
return
Expand All @@ -189,38 +189,43 @@ def publish_af(publisher, result_files, mda, **kwargs):
to_send["orig_orbit_number"] = to_send["orbit_number"]
to_send["orbit_number"] = kwargs['orbit']

to_send["dataset"] = []
for result_file in result_files:
filename = os.path.basename(result_file)
to_send[
'dataset'].append({'uri': urlunsplit(('ssh', socket.gethostname(),
result_file, '', '')),
'uid': filename})

publish_topic = kwargs.get('publish_topic', 'Unknown')
site = kwargs.get('site', 'unknown')
environment = kwargs.get('environment', 'unknown')

to_send['format'] = 'EDR'
to_send['type'] = 'NETCDF'
to_send['data_processing_level'] = '2'
to_send['start_time'], to_send['end_time'] = get_edr_times(filename)

LOG.debug('Site = %s', site)
LOG.debug('Publish topic = %s', publish_topic)
for topic in publish_topic:
msg = Message('/'.join(('',
topic,
to_send['format'],
to_send['data_processing_level'],
site,
environment,
'polar',
'direct_readout')),
"dataset", to_send).encode()

LOG.debug("sending: " + str(msg))
publisher.send(msg)
to_send['format'] = 'edr'

for result_file in result_files:
to_send['uri'] = urlunsplit(('ssh', socket.gethostname(),
result_file, '', ''))
filename = os.path.basename(result_file)
to_send['uid'] = filename
if filename.endswith('nc'):
to_send['type'] = 'netcdf'
elif filename.endswith('txt'):
to_send['type'] = 'txt'
else:
LOG.error("File type unknown! Don't publish. Filename = %s", filename)
return

to_send['start_time'], to_send['end_time'] = get_edr_times(filename)

LOG.debug('Site = %s', site)
LOG.debug('Publish topic = %s', publish_topic)
for topic in publish_topic:
msg = Message('/'.join(('',
topic,
to_send['format'],
to_send['data_processing_level'],
site,
environment,
'polar',
'direct_readout')),
"file", to_send).encode()

LOG.debug("sending: " + str(msg))
publisher.send(msg)


def viirs_active_fire_runner(options, service_name):
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[options]
setup_requires =
setuptools_scm
setuptools_scm_git_archive

[bdist_rpm]
requires=posttroll
release=1

no-autoreq=True

[bdist_wheel]
universal=1

Expand Down
16 changes: 9 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2019 Pytroll
# Copyright (c) 2019, 2020 Pytroll

# Author(s):

Expand All @@ -23,15 +23,16 @@
"""
"""


from setuptools import setup
import imp

version = imp.load_source(
'viirs_active_fires.version', 'viirs_active_fires/version.py')
try:
# HACK: https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
# Stop setuptools_scm from including all repository files
import setuptools_scm.integration
setuptools_scm.integration.find_files = lambda _: []
except ImportError:
pass

setup(name="pytroll-active-fire-runner",
version=version.__version__,
description='Pytroll runner for the VIIRS active fires',
author='Adam Dybroe',
author_email='adam.dybroe@smhi.se',
Expand All @@ -48,4 +49,5 @@
data_files=[],
zip_safe=False,
install_requires=['posttroll'],
use_scm_version=True,
)
12 changes: 9 additions & 3 deletions viirs_active_fires/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2019 Adam.Dybbroe
# Copyright (c) 2019, 2020 Adam.Dybbroe

# Author(s):

Expand All @@ -20,15 +20,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""
"""
"""Package initializer for viirs_active_fires."""

from pkg_resources import get_distribution, DistributionNotFound
import yaml
try:
from yaml import UnsafeLoader
except ImportError:
from yaml import Loader as UnsafeLoader

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass


def get_config(configfile, service, procenv):
"""Get the configuration from file"""
Expand Down
26 changes: 0 additions & 26 deletions viirs_active_fires/version.py

This file was deleted.

0 comments on commit af09f4d

Please sign in to comment.