File: usage.rst

package info (click to toggle)
pygac 1.7.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,144 kB
  • sloc: python: 5,425; makefile: 115
file content (106 lines) | stat: -rw-r--r-- 3,576 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Usage
-----

Through Satpy
~~~~~~~~~~~~~

The preferred way of using Pygac is through `Satpy`_. Results are returned as
dask-friendly `xarray`_ DataArrays with proper dataset/coordinate names and
additional metadata. It is also possible to select a user-defined range of
scanlines. Furthermore, Satpy provides many options for resampling,
visualizing and saving the data.

.. code-block:: python

    import satpy

    # Channel set for KLM satellites. For POD satellites the channels are
    # ['1', '2', '3', '4', '5'].
    channels = ['1', '2', '3a', '3b', '4', '5']
    ancillary = ['solar_zenith_angle',
                 'sensor_zenith_angle',
                 'solar_azimuth_angle',
                 'sensor_azimuth_angle',
                 'sun_sensor_azimuth_difference_angle',
                 'qual_flags',
                 'latitude',
                 'longitude']

    scene = satpy.Scene(filenames=['NSS.GHRR.NP.D15361.S0121.E0315.B3547172.SV'],
                        reader='avhrr_l1b_gaclac',
                        reader_kwargs={'tle_dir': '/path/to/tle/',
                                       'tle_name': 'TLE_%(satname)s.txt'})
    scene.load(channels + ancillary)


For a list of Satpy reader keyword arguments see `satpy.readers.avhrr_l1b_gaclac`_
and for further Pygac reader keyword arguments see :class:`pygac.reader.Reader`.
Especially it is possible to choose a different version of calibration
coefficients or even specify your own.

.. _Satpy: https://satpy.readthedocs.io
.. _xarray: https://xarray.pydata.org
.. _satpy.readers.avhrr_l1b_gaclac:
    https://satpy.readthedocs.io/en/stable/api/satpy.readers.avhrr_l1b_gaclac.html?highlight=avhrr_l1b_gaclac
.. _example notebook:
    https://github.com/pytroll/pytroll-examples/blob/main/satpy/avhrr_l1b_gaclac.ipynb


Direct Usage
~~~~~~~~~~~~

Alternatively you can also use Pygac directly.

.. code-block:: python

    from pygac import get_reader_class

    filename = 'NSS.GHRR.NP.D15361.S0121.E0315.B3547172.SV'
    reader_cls = get_reader_class(filename)
    reader = reader_cls(tle_dir='/path/to/tle', tle_name='TLE_%(satname)s.txt')
    reader.read(filename)

    channels = reader.get_calibrated_channels()
    lons, lats = reader.get_lonlat()
    scanline_times = reader.get_times()
    bad_quality_lines = reader.mask


Legacy CLI
~~~~~~~~~~

.. note::

    Usage of the legacy command line program ``pygac-run`` is deprecated in
    favour of the above options.

There is also a legacy command line program ``pygac-run`` which saves the
results to HDF5 and requires a configuration file.

Copy the template file ``etc/pygac.cfg.template`` to ``pygac.cfg`` and place
it in a directory as you please. Set the environment variable ``PYGAC_CONFIG_FILE``
pointing to the file. e.g.

.. code-block:: bash

  PYGAC_CONFIG_FILE=/home/user/pygac.cfg; export PYGAC_CONFIG_FILE

Also adapt the configuration file to your needs. The ``tledir`` parameter should
be set to where your Two Line Element (TLE) files are located.

Then call ``pygac-run`` on a GAC/LAC file.

.. code-block:: bash

  pygac-run testdata/NSS.GHRR.NL.D02187.S1904.E2058.B0921517.GC 0 0

The last two digits are the start and end scanline numbers, thus specifying the
portion of the GAC orbit that user wants to process. The first scanline number
starts at 0. If zeroes are specified at both locations, then the entire orbit
will be processed.

The result will be three hdf5 files, one with the calibrated AVHRR data,
the other with sun-satellite viewing geometry data and this third with
scanline quality information.