Skip to content

Commit

Permalink
Merge pull request #47 from adybbroe/pmw_instrument_geometries
Browse files Browse the repository at this point in the history
Add support for MWHS-2 (FY-3) and skip edge-functions
  • Loading branch information
adybbroe committed Oct 17, 2019
2 parents bccf75e + 553bb8d commit 7efe253
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 48 deletions.
3 changes: 2 additions & 1 deletion pyorbital/geoloc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2017.
# Copyright (c) 2011 - 2019 Pytroll Community

# Author(s):

# Martin Raspaud <martin.raspaud@smhi.se>
# Adam Dybbroe <adam.dybbroe@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
Expand Down
140 changes: 94 additions & 46 deletions pyorbital/geoloc_instrument_definitions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2013 - 2018 PyTroll Community
# Copyright (c) 2013 - 2019 PyTroll Community

# Author(s):

Expand Down Expand Up @@ -209,14 +209,14 @@ def viirs_edge_geom(scans_nb):
#
################################################################

def amsua(scans_nb, edges_only=False):
def amsua(scans_nb, scan_points=None):
""" Describe AMSU-A instrument geometry
Parameters:
scans_nb | int - number of scan lines
Keywords:
* edges_only - use only edge pixels
* scan_points - FIXME!
Returns:
pyorbital.geoloc.ScanGeometry object
Expand All @@ -229,9 +229,7 @@ def amsua(scans_nb, edges_only=False):
sampling_interval = 0.2 # single view, seconds
sync_time = 0.00355 # delay before the actual scan starts

if edges_only:
scan_points = np.array([0, scan_len - 1])
else:
if scan_points is None:
scan_points = np.arange(0, scan_len)

# build the instrument (scan angles)
Expand All @@ -250,18 +248,13 @@ def amsua(scans_nb, edges_only=False):
return ScanGeometry(samples, times)


def amsua_edge_geom(scans_nb):
# we take only edge pixels
return amsua(scans_nb, edges_only=True)


################################################################
#
# MHS
#
################################################################

def mhs(scans_nb, edges_only=False):
def mhs(scans_nb, scan_points=None):
""" Describe MHS instrument geometry
See:
Expand All @@ -275,7 +268,7 @@ def mhs(scans_nb, edges_only=False):
scans_nb | int - number of scan lines
Keywords:
* edges_only - use only edge pixels
* scan_points - FIXME!
Returns:
pyorbital.geoloc.ScanGeometry object
Expand All @@ -286,30 +279,32 @@ def mhs(scans_nb, edges_only=False):
scan_rate = 8 / 3. # single scan, seconds
scan_angle = -49.444 # swath, degrees
sampling_interval = (8 / 3. - 1) / 90. # single view, seconds
sync_time = 0.0 # delay before the actual scan starts - don't know! FIXME!

if edges_only:
scan_points = np.array([0, scan_len - 1])
else:
if scan_points is None:
scan_points = np.arange(0, scan_len)

# build the instrument (scan angles)
samples = np.vstack(((scan_points / (scan_len * 0.5 - 0.5) - 1)
* np.deg2rad(scan_angle),
samples = np.vstack(((scan_points / (scan_len * 0.5 - 0.5) - 1) * np.deg2rad(scan_angle),
np.zeros((len(scan_points),))))
samples = np.tile(samples[:, np.newaxis, :], [1, np.int(scans_nb), 1])

# building the corresponding times array
offset = np.arange(scans_nb) * scan_rate
times = (np.tile(scan_points * sampling_interval, [np.int(scans_nb), 1])
+ np.expand_dims(offset, 1))
times = (np.tile(scan_points * sampling_interval + sync_time, [np.int(scans_nb), 1]) + np.expand_dims(offset, 1))

# build the scan geometry object
return ScanGeometry(samples, times)
# scan_angles = np.linspace(-np.deg2rad(scan_angle), np.deg2rad(scan_angle), scan_len)[scan_points]

# samples = np.vstack((scan_angles, np.zeros(len(scan_points) * 1,)))
# samples = np.tile(samples[:, np.newaxis, :], [1, np.int(scans_nb), 1])

def mhs_edge_geom(scans_nb):
# we take only edge pixels
return mhs(scans_nb, edges_only=True)
# # building the corresponding times array
# offset = np.arange(scans_nb) * scan_rate
# times = (np.tile(scan_points * sampling_interval, [np.int(scans_nb), 1])
# + np.expand_dims(offset, 1))

# build the scan geometry object
return ScanGeometry(samples, times)


################################################################
Expand All @@ -318,7 +313,7 @@ def mhs_edge_geom(scans_nb):
#
################################################################

def hirs4(scans_nb, edges_only=False):
def hirs4(scans_nb, scan_points=None):
"""Describe HIRS/4 instrument geometry.
See:
Expand All @@ -331,7 +326,7 @@ def hirs4(scans_nb, edges_only=False):
scans_nb | int - number of scan lines
Keywords:
* edges_only - use only edge pixels
* scan_points - FIXME!
Returns:
pyorbital.geoloc.ScanGeometry object
Expand All @@ -343,9 +338,7 @@ def hirs4(scans_nb, edges_only=False):
scan_angle = -49.5 # swath, degrees
sampling_interval = abs(scan_rate) / scan_len # single view, seconds

if edges_only:
scan_points = np.array([0, scan_len - 1])
else:
if scan_points is None:
scan_points = np.arange(0, scan_len)

# build the instrument (scan angles)
Expand All @@ -363,19 +356,14 @@ def hirs4(scans_nb, edges_only=False):
return ScanGeometry(samples, times)


def hirs4_edge_geom(scans_nb):
# we take only edge pixels
return hirs4(scans_nb, edges_only=True)


################################################################
#
# ATMS
#
################################################################

def atms(scans_nb, edges_only=False):
""" Describe MHS instrument geometry
def atms(scans_nb, scan_points=None):
""" Describe ATMS instrument geometry
See:
- https://dtcenter.org/com-GSI/users/docs/presentations/2013_workshop/
Expand All @@ -388,7 +376,7 @@ def atms(scans_nb, edges_only=False):
scans_nb | int - number of scan lines
Keywords:
* edges_only - use only edge pixels
* scan_points - FIXME!
Returns:
pyorbital.geoloc.ScanGeometry object
Expand All @@ -400,9 +388,61 @@ def atms(scans_nb, edges_only=False):
scan_angle = -52.7 # swath, degrees
sampling_interval = 18e-3 # single view, seconds

if edges_only:
scan_points = np.array([0, scan_len - 1])
else:
if scan_points is None:
scan_points = np.arange(0, scan_len)

# build the instrument (scan angles)
scan_angles = np.linspace(-np.deg2rad(scan_angle), np.deg2rad(scan_angle), scan_len)[scan_points]

samples = np.vstack((scan_angles, np.zeros(len(scan_points) * 1,)))
samples = np.tile(samples[:, np.newaxis, :], [1, np.int(scans_nb), 1])

# building the corresponding times array
offset = np.arange(scans_nb) * scan_rate
times = (np.tile(scan_points * sampling_interval, [np.int(scans_nb), 1])
+ np.expand_dims(offset, 1))

# build the scan geometry object
return ScanGeometry(samples, times)


################################################################
#
# MWHS-2
#
################################################################

def mwhs2(scans_nb, scan_points=None):
"""Describe MWHS-2 instrument geometry
The scanning period is 2.667 s. Main beams of the antenna scan over the ob-
serving swath (±53.35◦ from nadir) in the cross-track direction at a
constant time of 1.71 s. There are 98 pixels sampled per scan during 1.71s,
and each sample has the same integration period.
See:
http://english.nssc.cas.cn/rh/rp/201501/W020150122580098790190.pdf
Parameters:
scans_nb | int - number of scan lines
Keywords:
* scan_points - FIXME!
Returns:
pyorbital.geoloc.ScanGeometry object
"""

scan_len = 98 # 98 samples per scan
scan_rate = 8 / 3. # single scan, seconds
scan_angle = -53.35 # swath, degrees
sampling_interval = (8 / 3. - 1) / 98. # single view, seconds
# sampling_interval = 17.449e-3 # single view, seconds
sync_time = 0.0 # delay before the actual scan starts - don't know! FIXME!

if scan_points is None:
scan_points = np.arange(0, scan_len)

# build the instrument (scan angles)
Expand All @@ -413,17 +453,25 @@ def atms(scans_nb, edges_only=False):

# building the corresponding times array
offset = np.arange(scans_nb) * scan_rate
times = (np.tile(scan_points * sampling_interval, [np.int(scans_nb), 1])
times = (np.tile(scan_points * sampling_interval + sync_time,
[np.int(scans_nb), 1])
+ np.expand_dims(offset, 1))

# # build the instrument (scan angles)
# scan_angles = np.linspace(-np.deg2rad(scan_angle), np.deg2rad(scan_angle), scan_len)[scan_points]

# samples = np.vstack((scan_angles, np.zeros(len(scan_points) * 1,)))
# samples = np.tile(samples[:, np.newaxis, :], [1, np.int(scans_nb), 1])

# # building the corresponding times array
# offset = np.arange(scans_nb) * scan_rate
# times = (np.tile(scan_points * sampling_interval, [np.int(scans_nb), 1])
# + np.expand_dims(offset, 1))

# build the scan geometry object
return ScanGeometry(samples, times)


def atms_edge_geom(scans_nb):
# we take only edge pixels
return atms(scans_nb, edges_only=True)

################################################################
#
# OLCI
Expand Down
2 changes: 1 addition & 1 deletion pyorbital/tlefile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2011 - 2018
# Copyright (c) 2011 - 2019

# Author(s):

Expand Down

0 comments on commit 7efe253

Please sign in to comment.