Skip to content

Commit

Permalink
Merge pull request #30 from sfinkens/fix-minor-issues
Browse files Browse the repository at this point in the history
Fix minor issues
  • Loading branch information
sfinkens authored Sep 11, 2020
2 parents dc326a3 + e215be3 commit ceb31a8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 11 deletions.
41 changes: 41 additions & 0 deletions bin/pygac-fdr-dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 pygac-fdr developers
#
# This file is part of pygac-fdr.
#
# pygac-fdr 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.
#
# pygac-fdr 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
# pygac-fdr. If not, see <http://www.gnu.org/licenses/>.
"""Print contents of metadata database."""

import argparse
import pandas as pd

from pygac_fdr.metadata import MetadataCollector


if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('dbfile', help='Metadata database')
parser.add_argument('-n', help='Maximum number of rows to be printed',
type=int)
args = parser.parse_args()

collector = MetadataCollector()
mda = collector.read_sql(args.dbfile)

pd.set_option('display.max_rows', args.n)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', 22)

print(mda)
7 changes: 0 additions & 7 deletions bin/pygac-fdr-mda-collect
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ if __name__ == '__main__':
parser.add_argument('--verbose', action='store_true', help='Increase verbosity')
args = parser.parse_args()
logging_on(logging.DEBUG if args.verbose else logging.INFO)
if args.verbose:
import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', 22)

collector = MetadataCollector()
mda = collector.get_metadata(args.filenames)
LOG.debug(mda)
collector.save_sql(mda, args.dbfile, args.if_exists)
9 changes: 7 additions & 2 deletions pygac_fdr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import os
import satpy
import trollsift


BANDS = ['1', '2', '3', '3a', '3b', '4', '5']
AUX_DATA = ['latitude',
Expand All @@ -30,6 +32,8 @@
'solar_azimuth_angle',
'sensor_azimuth_angle',
'sun_sensor_azimuth_difference_angle']
GAC_FORMAT = '{creation_site:3s}.{transfer_mode:4s}.{platform_id:2s}.D{start_time:%y%j.S%H%M}.' \
'E{end_time:%H%M}.B{orbit_number:05d}{end_orbit_last_digits:02d}.{station:2s}'


def read_gac(filename, reader_kwargs=None):
Expand All @@ -47,10 +51,11 @@ def read_gac(filename, reader_kwargs=None):
scene.load(AUX_DATA)

# Add additional metadata
fname_info = scene.readers['avhrr_l1b_gaclac'].file_handlers['gac_lac_l1b'][0].filename_info
basename = os.path.basename(filename)
fname_info = trollsift.parse(GAC_FORMAT, basename)
orbit_number_end = fname_info['orbit_number'] // 100 * 100 + fname_info['end_orbit_last_digits']
scene.attrs.update({
'gac_filename': os.path.basename(filename),
'gac_filename': basename,
'orbit_number_start': fname_info['orbit_number'],
'orbit_number_end': orbit_number_end,
'ground_station': fname_info['station']
Expand Down
2 changes: 1 addition & 1 deletion pygac_fdr/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
DATASET_NAMES = {
'1': 'reflectance_channel_1',
'2': 'reflectance_channel_2',
'3': 'reflectance_channel_3',
'3': 'brightness_temperature_channel_3',
'3a': 'reflectance_channel_3a',
'3b': 'brightness_temperature_channel_3b',
'4': 'brightness_temperature_channel_4',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

if __name__ == '__main__':
requires = ['setuptools_scm', 'numpy', 'xarray >=0.15.1', 'pandas >=1.0.3', 'netCDF4',
'h5py', 'pygac >=1.3.1', 'satpy >=0.21.0', 'pyyaml']
'h5py', 'pygac >=1.3.1', 'satpy >=0.21.0', 'pyyaml', 'trollsift']
README = open('README.md', 'r').read()
setup(name='pygac-fdr',
description='Python package for creating a Fundamental Data Record (FDR) of AVHRR GAC '
Expand Down

0 comments on commit ceb31a8

Please sign in to comment.