Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update safe_msi for new pyproj compatibility #1259

Merged
merged 2 commits into from Jul 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions satpy/readers/msi_safe.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2016-2017 Satpy developers
# Copyright (c) 2016-2020 Satpy developers
#
# This file is part of satpy.
#
Expand All @@ -15,8 +15,7 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""SAFE MSI L1C reader.
"""
"""SAFE MSI L1C reader."""

import logging

Expand All @@ -41,8 +40,10 @@


class SAFEMSIL1C(BaseFileHandler):
"""File handler for SAFE MSI files (jp2)."""

def __init__(self, filename, filename_info, filetype_info, mda):
"""Init the reader."""
super(SAFEMSIL1C, self).__init__(filename, filename_info,
filetype_info)

Expand Down Expand Up @@ -85,21 +86,26 @@ def get_dataset(self, key, info):

@property
def start_time(self):
"""Get the start time."""
return self._start_time

@property
def end_time(self):
"""Get the end time."""
return self._start_time

def get_area_def(self, dsid):
"""Get the area def."""
if self._channel != dsid.name:
return
return self._mda.get_area_def(dsid)


class SAFEMSIMDXML(BaseFileHandler):
"""File handle for sentinel 2 safe XML manifest."""

def __init__(self, filename, filename_info, filetype_info):
"""Init the reader."""
super(SAFEMSIMDXML, self).__init__(filename, filename_info,
filetype_info)
self._start_time = filename_info['observation_time']
Expand All @@ -110,14 +116,17 @@ def __init__(self, filename, filename_info, filetype_info):

@property
def start_time(self):
"""Get start time."""
return self._start_time

@property
def end_time(self):
"""Get end time."""
return self._start_time

def get_area_def(self, dsid):
"""Get the area definition of the dataset."""
from pyproj import CRS
geocoding = self.root.find('.//Tile_Geocoding')
epsg = geocoding.find('HORIZONTAL_CS_CODE').text
rows = int(geocoding.find('Size[@resolution="' + str(dsid.resolution) + '"]/NROWS').text)
Expand All @@ -132,7 +141,7 @@ def get_area_def(self, dsid):
self.tile,
"On-the-fly area",
self.tile,
{'init': epsg},
CRS(epsg),
cols,
rows,
area_extent)
Expand All @@ -145,6 +154,7 @@ def _do_interp(minterp, xcoord, ycoord):
return res.reshape(xcoord.shape)

def interpolate_angles(self, angles, resolution):
"""Interpolate the angles."""
# FIXME: interpolate in cartesian coordinates if the lons or lats are
# problematic
from geotiepoints.multilinear import MultilinearInterpolator
Expand Down Expand Up @@ -185,7 +195,6 @@ def _get_coarse_dataset(self, key, info):

def get_dataset(self, key, info):
"""Get the dataset refered to by `key`."""

angles = self._get_coarse_dataset(key, info)
if angles is None:
return
Expand Down