Skip to content

Commit

Permalink
fix return of field_of_view
Browse files Browse the repository at this point in the history
  • Loading branch information
blaylockbk committed Apr 10, 2023
1 parent 257f1ef commit 351e3de
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
3 changes: 1 addition & 2 deletions goes2go/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ def full_disk(self):
FOV_degrees -= 0.06
FOV_radius = np.radians(FOV_degrees / 2) * sat_height
FOV_polygon = Point(0, 0).buffer(FOV_radius, resolution=160)
return FOV_polygon
elif ds.title.startswith("GLM"):
# Field of view (FOV) of GLM is different than ABI.
# Do a little offset to better match boundary from
Expand All @@ -240,7 +239,7 @@ def full_disk(self):
)
cutout = Polygon(cutout_points)
FOV_polygon = FOV_polygon.intersection(cutout)
return FOV_polygon
return FOV_polygon

@property
def domain(self):
Expand Down
32 changes: 16 additions & 16 deletions goes2go/rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
.. image:: /_static/RGB_sample.png
These functions take GOES-East or GOES-West multichannel data on a
fixed grid (files named ``ABI-L2-MCMIPC``) and generates a 3D
These functions take GOES-East or GOES-West multichannel data on a
fixed grid (files named ``ABI-L2-MCMIPC``) and generates a 3D
Red-Green-Blue (RGB) array for various GOES RGB products.
RGB recipes are based on the `GOES Quick Guides
<http://rammb.cira.colostate.edu/training/visit/quick_guides/>`_
<http://rammb.cira.colostate.edu/training/visit/quick_guides/>`_
and include the following:
- NaturalColor
Expand All @@ -36,38 +36,38 @@
- NightFogDifference
- RocketPlume ✨New - July 9, 2021
The returned RGB can easily be viewed with ``plt.imshow(RGB)``.
The returned RGB can easily be viewed with ``plt.imshow(RGB)``.
For imshow to show an RGB image, the values must range between 0 and 1.
Values are normalized between the range specified in the Quick Guides.
This normalization is synonymous to `contrast or histogram stretching
For imshow to show an RGB image, the values must range between 0 and 1.
Values are normalized between the range specified in the Quick Guides.
This normalization is synonymous to `contrast or histogram stretching
<https://micro.magnet.fsu.edu/primer/java/digitalimaging/processing/histogramstretching/index.html>`_
(`more info here
<https://staff.fnwi.uva.nl/r.vandenboomgaard/IPCV20162017/LectureNotes/IP/PointOperators/ImageStretching.html>`_)
and follows the formula:
.. code-block:: python
.. code-block:: python
NormalizedValue = (OriginalValue-LowerLimit)/(UpperLimit-LowerLimit)
`Gamma correction <https://en.wikipedia.org/wiki/Gamma_correction>`_
darkens or lightens an image (`more info
<https://www.cambridgeincolour.com/tutorials/gamma-correction.htm>`_)
darkens or lightens an image (`more info
<https://www.cambridgeincolour.com/tutorials/gamma-correction.htm>`_)
and follows the decoding formula:
.. code-block:: python
.. code-block:: python
R_corrected = R**(1/gamma)
The input for all these functions are denoted by ``C`` for "channels" which
represents the GOES ABI multichannel file opened with xarray. For example:
.. code-block:: python
.. code-block:: python
FILE = 'OR_ABI-L2-MCMIPC-M6_G17_s20192201631196_e20192201633575_c20192201634109.nc'
C = xarray.open_dataset(FILE)
All RGB products are demonstarted in the `make_RGB_Demo
All RGB products are demonstarted in the `make_RGB_Demo
<https://github.com/blaylockbk/goes2go/tree/master/notebooks>`_ notebook.
Note: I don't have a `GeoColor <https://journals.ametsoc.org/view/journals/atot/37/3/JTECH-D-19-0134.1.xml>`_
Expand Down Expand Up @@ -164,7 +164,7 @@ def rgb_as_dataset(G, RGB, description, latlon=False):
ds.attrs["description"] = description

# Convert x, y points to latitude/longitude
_, crs = field_of_view(G)
_, _, crs = field_of_view(G)
sat_h = G.goes_imager_projection.perspective_point_height
x2 = G.x * sat_h
y2 = G.y * sat_h
Expand Down
28 changes: 17 additions & 11 deletions goes2go/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def field_of_view(G, resolution=60, reduce_abi_fov=0.06):
.. code:: python
FOV, geo = field_of_view(G)
ax = plt.subplot(projection=geo)
ax.add_geometries([FOV], crs=geo)
pFOV_inst, pFOV_dom, crs = field_of_view(G)
ax = plt.subplot(projection=crs)
ax.add_geometries([FOV], crs=crs)
Parameters
----------
Expand All @@ -51,6 +51,12 @@ def field_of_view(G, resolution=60, reduce_abi_fov=0.06):
plane. If this number is less than the default, the polygon
will not be calculated correctly because edge points will lie
off the projection globe.
Returns
-------
pFOV_inst is a polygon of the instrument field of view.
pFOV_dom is a polygon of the domain field of view
crs is the cartopy coordinate reference system for the instrument
"""
warnings.warn(
"DEPRECIATION. Use the FOV accessor instead `G.FOV.full_disk` or `G.FOV.domain`"
Expand Down Expand Up @@ -97,7 +103,7 @@ def field_of_view(G, resolution=60, reduce_abi_fov=0.06):
# we are working in the geostationary projection coordinates
# and the center point is 0,0 meters.
FOV_radius = np.radians(FOV / 2) * sat_height
FOV_poly = Point(0, 0).buffer(FOV_radius, resolution=resolution)
pFOV_inst = Point(0, 0).buffer(FOV_radius, resolution=resolution)

## GLM is a bit funny. I haven't found this in the documentation
## anywhere, yet, but the GLM field-of-view is not exactly
Expand Down Expand Up @@ -127,22 +133,22 @@ def field_of_view(G, resolution=60, reduce_abi_fov=0.06):
x = np.hstack([side1x, side2x, side3x, side4x])
y = np.hstack([side1y, side2y, side3y, side4y])
square_FOV = Polygon(zip(x, y))
FOV_poly = FOV_poly.intersection(square_FOV)

return FOV_poly, crs
pFOV_inst = pFOV_inst.intersection(square_FOV)
pFOV_dom = None # there is no "domain" for the GLM instrument

if G.title.startswith("ABI"):
# We have the global field of view
# We have the global field of view,
# now we need the domain field of view
dom_border = np.array(
[(i, G.y.data[0]) for i in G.x.data]
+ [(G.x.data[-1], i) for i in G.y.data]
+ [(i, G.y.data[-1]) for i in G.x.data[::-1]]
+ [(G.x.data[0], i) for i in G.y.data[::-1]]
)
FOV_dom = Polygon(dom_border * sat_height)
FOV_dom = FOV_dom.intersection(FOV_poly)
return FOV_poly, FOV_dom, crs
pFOV_dom = Polygon(dom_border * sat_height)
pFOV_dom = pFOV_dom.intersection(pFOV_inst)

return pFOV_inst, pFOV_dom, crs


def abi_crs(G, reference_variable="CMI_C01"):
Expand Down

0 comments on commit 351e3de

Please sign in to comment.