Beispiel #1
0
def modis5kmto1km(lons5km, lats5km):
    """Getting 1km geolocation for modis from 5km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    from geotiepoints.geointerpolator import \
        GeoInterpolator as SatelliteInterpolator

    # FIXME: I changed the values here to work with MOD06 - but why?!
    cols5km = np.arange(2, 1350, 5) / 5.0
    cols1km = np.arange(1350) / 5.0
    lines = lons5km.shape[0] * 5
    rows5km = np.arange(2, lines, 5) / 5.0
    rows1km = np.arange(lines) / 5.0

    along_track_order = 1
    cross_track_order = 3

    satint = SatelliteInterpolator((lons5km, lats5km),
                                   (rows5km, cols5km),
                                   (rows1km, cols1km),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=10)
    satint.fill_borders("y", "x")
    lons1km, lats1km = satint.interpolate()
    return lons1km, lats1km
Beispiel #2
0
def modis1kmto250m(lons1km, lats1km, cores=1):
    """Getting 250m geolocation for modis from 1km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    if cores > 1:
        return _multi(modis1kmto250m, lons1km, lats1km, 10, cores)

    cols1km = np.arange(1354)
    cols250m = np.arange(1354 * 4) / 4.0

    along_track_order = 1
    cross_track_order = 3

    lines = lons1km.shape[0]
    rows1km = np.arange(lines)
    rows250m = (np.arange(lines * 4) - 1.5) / 4.0

    satint = SatelliteInterpolator((lons1km, lats1km), (rows1km, cols1km),
                                   (rows250m, cols250m),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=40)
    satint.fill_borders("y", "x")
    lons250m, lats250m = satint.interpolate()

    return lons250m, lats250m
Beispiel #3
0
def modis5kmto1km(lons5km, lats5km):
    """Getting 1km geolocation for modis from 5km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    from geotiepoints.geointerpolator import \
        GeoInterpolator as SatelliteInterpolator

    # FIXME: I changed the values here to work with MOD06 - but why?!
    cols5km = np.arange(2, 1350, 5) / 5.0
    cols1km = np.arange(1350) / 5.0
    lines = lons5km.shape[0] * 5
    rows5km = np.arange(2, lines, 5) / 5.0
    rows1km = np.arange(lines) / 5.0

    along_track_order = 1
    cross_track_order = 3

    satint = SatelliteInterpolator((lons5km, lats5km), (rows5km, cols5km),
                                   (rows1km, cols1km),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=10)
    satint.fill_borders("y", "x")
    lons1km, lats1km = satint.interpolate()
    return lons1km, lats1km
def modis1kmto250m(lons1km, lats1km, cores=1):
    """Getting 250m geolocation for modis from 1km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    if cores > 1:
        return _multi(modis1kmto250m, lons1km, lats1km, 10, cores)

    cols1km = np.arange(1354)
    cols250m = np.arange(1354 * 4) / 4.0

    along_track_order = 1
    cross_track_order = 3

    lines = lons1km.shape[0]
    rows1km = np.arange(lines)
    rows250m = (np.arange(lines * 4) - 1.5) / 4.0

    satint = SatelliteInterpolator((lons1km, lats1km),
                                   (rows1km, cols1km),
                                   (rows250m, cols250m),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=40)
    satint.fill_borders("y", "x")
    lons250m, lats250m = satint.interpolate()

    return lons250m, lats250m
Beispiel #5
0
def modis1kmto250m(lons1km, lats1km, cores=1):
    """Getting 250m geolocation for modis from 1km tiepoints.
    """
    if cores > 1:
        return _multi(modis1kmto250m, lons1km, lats1km, 10, cores)
    
    cols1km = np.arange(0, 5416, 4)
    cols250m = np.arange(5416)

    along_track_order = 1
    cross_track_order = 3
    
    lines = lons1km.shape[0] * 4
    rows1km = np.arange(1.5, lines, 4)
    rows250m = np.arange(lines)

    satint = SatelliteInterpolator((lons1km, lats1km),
                                   (rows1km, cols1km),
                                   (rows250m, cols250m),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=40)
    satint.fill_borders("y", "x")
    lons250m, lats250m = satint.interpolate()

    return lons250m, lats250m
    def test_fillborders(self):
        lons = np.arange(20).reshape((4, 5), order="F")
        lats = np.arange(20).reshape((4, 5), order="C")
        lines = np.array([2, 7, 12, 17]) / 5.0
        cols = np.array([2, 7, 12, 17, 22])
        hlines = np.arange(20) / 5.0
        hcols = np.arange(24)
        satint = GeoInterpolator(
            (lons, lats), (lines, cols), (hlines, hcols), chunk_size=10)
        satint.fill_borders('x', 'y')

        np.testing.assert_allclose(satint.tie_data[0], TIES_EXP1)
        np.testing.assert_allclose(satint.row_indices, np.array(
            [0,  2,  7,  9, 10, 12, 17, 19]) / 5.0)
        self.assertTrue(
            np.allclose(satint.col_indices, np.array([0,  2,  7, 12, 17, 22, 23])))
    def test_fillborders(self):
        lons = np.arange(20).reshape((4, 5), order="F")
        lats = np.arange(20).reshape((4, 5), order="C")
        lines = np.array([2, 7, 12, 17]) / 5.0
        cols = np.array([2, 7, 12, 17, 22])
        hlines = np.arange(20) / 5.0
        hcols = np.arange(24)
        satint = GeoInterpolator((lons, lats), (lines, cols), (hlines, hcols),
                                 chunk_size=10)
        satint.fill_borders('x', 'y')

        np.testing.assert_allclose(satint.tie_data[0], TIES_EXP1)
        np.testing.assert_allclose(
            satint.row_indices,
            np.array([0, 2, 7, 9, 10, 12, 17, 19]) / 5.0)
        self.assertTrue(
            np.allclose(satint.col_indices, np.array([0, 2, 7, 12, 17, 22,
                                                      23])))
Beispiel #8
0
def modis5kmto1km(lons5km, lats5km):
    """Getting 1km geolocation for modis from 5km tiepoints.
    """
    cols5km = np.arange(2, 1354, 5)
    cols1km = np.arange(1354)
    lines = lons5km.shape[0] * 5
    rows5km = np.arange(2, lines, 5)
    rows1km = np.arange(lines)

    along_track_order = 1
    cross_track_order = 3

    satint = SatelliteInterpolator((lons5km, lats5km),
                                   (rows5km, cols5km),
                                   (rows1km, cols1km),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=10)
    satint.fill_borders("y", "x")
    lons1km, lats1km = satint.interpolate()
    return lons1km, lats1km
Beispiel #9
0
def modis5kmto1km(lons5km, lats5km):
    """Getting 1km geolocation for modis from 5km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    cols5km = np.arange(2, 1354, 5) / 5.0
    cols1km = np.arange(1354) / 5.0
    lines = lons5km.shape[0] * 5
    rows5km = np.arange(2, lines, 5) / 5.0
    rows1km = np.arange(lines) / 5.0

    along_track_order = 1
    cross_track_order = 3

    satint = SatelliteInterpolator((lons5km, lats5km), (rows5km, cols5km),
                                   (rows1km, cols1km),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=10)
    satint.fill_borders("y", "x")
    lons1km, lats1km = satint.interpolate()
    return lons1km, lats1km
Beispiel #10
0
def modis5kmto1km(lons5km, lats5km):
    """Getting 1km geolocation for modis from 5km tiepoints.

    http://www.icare.univ-lille1.fr/tutorials/MODIS_geolocation
    """
    cols5km = np.arange(2, 1354, 5) / 5.0
    cols1km = np.arange(1354) / 5.0
    lines = lons5km.shape[0] * 5
    rows5km = np.arange(2, lines, 5) / 5.0
    rows1km = np.arange(lines) / 5.0

    along_track_order = 1
    cross_track_order = 3

    satint = SatelliteInterpolator((lons5km, lats5km),
                                   (rows5km, cols5km),
                                   (rows1km, cols1km),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=10)
    satint.fill_borders("y", "x")
    lons1km, lats1km = satint.interpolate()
    return lons1km, lats1km
 def test_fillborders(self):
     lons = np.arange(20).reshape((4, 5), order="F")
     lats = np.arange(20).reshape((4, 5), order="C")
     lines = np.array([2, 7, 12, 17])
     cols = np.array([2, 7, 12, 17, 22])
     hlines = np.arange(20)
     hcols = np.arange(24)
     satint = GeoInterpolator((lons, lats), (lines, cols), (hlines, hcols), chunk_size=10)
     satint.fill_borders('x', 'y')
     self.assertTrue(np.allclose(satint.tie_data[0],
       np.array([[ 6384905.78040055,  6381081.08333225,  6371519.34066148,
                   6328950.00792935,  6253610.69157758,  6145946.19489936,
                   6124413.29556372],
                 [ 6377591.95940176,  6370997.        ,  6354509.6014956 ,
                   6305151.62592155,  6223234.99818839,  6109277.14889072,
                   6086485.57903118],
                 [ 6359307.40690478,  6345786.79166939,  6311985.2535809 ,
                   6245655.67090206,  6147295.76471541,  6017604.5338691 ,
                   5991666.28769983],
                 [ 6351993.58590599,  6335702.70833714,  6294975.51441502,
                   6221857.28889426,  6116920.07132621,  5980935.48786045,
                   5953738.5711673 ],
                 [ 6338032.26190294,  6320348.4990906 ,  6276139.09205974,
                   6199670.56624433,  6091551.90273768,  5952590.38414781,
                   5924798.08042984],
                 [ 6290665.5946295 ,  6270385.16249031,  6219684.08214232,
                   6137100.75832981,  6023313.2794414 ,  5879194.72399075,
                   5850371.01290062],
                 [ 6172248.92644589,  6145476.82098957,  6078546.55734877,
                   5980676.23854351,  5852716.72120069,  5695705.57359808,
                   5664303.34407756],
                 [ 6124882.25917245,  6095513.48438928,  6022091.54743135,
                   5918106.430629  ,  5784478.09790441,  5622309.91344102,
                   5589876.27654834]])))
     self.assertTrue(np.allclose(satint.row_indices, np.array([ 0,  2,  7,  9, 10, 12, 17, 19])))
     self.assertTrue(np.allclose(satint.col_indices, np.array([ 0,  2,  7, 12, 17, 22, 23])))
Beispiel #12
0
def modis1kmto500m(lons1km, lats1km, cores=1):
    """Getting 500m geolocation for modis from 1km tiepoints.
    """
    if cores > 1:
        return _multi(modis1kmto500m, lons1km, lats1km, 10, cores)
    
    cols1km = np.arange(0, 2708, 2)
    cols500m = np.arange(2708)
    lines = lons1km.shape[0] * 2
    rows1km = np.arange(0.5, lines, 2)
    rows500m = np.arange(lines)

    along_track_order = 1
    cross_track_order = 3
    
    satint = SatelliteInterpolator((lons1km, lats1km),
                                   (rows1km, cols1km),
                                   (rows500m, cols500m),
                                   along_track_order,
                                   cross_track_order,
                                   chunk_size=20)
    satint.fill_borders("y", "x")
    lons500m, lats500m = satint.interpolate()
    return lons500m, lats500m
#   Adam.Dybbroe <*****@*****.**>

# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

"""
"""

import numpy as np
from geotiepoints.geointerpolator import GeoInterpolator

lons = np.arange(20).reshape((4, 5), order="F")
lats = np.arange(20).reshape((4, 5), order="C")
lines = np.array([2, 7, 12, 17]) / 5.0
cols = np.array([2, 7, 12, 17, 22])
hlines = np.arange(20) / 5.0
hcols = np.arange(24)
satint = GeoInterpolator(
    (lons, lats), (lines, cols), (hlines, hcols), chunk_size=10)
satint.fill_borders('x', 'y')
Beispiel #14
0
#   Adam.Dybbroe <*****@*****.**>

# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
"""
"""

import numpy as np
from geotiepoints.geointerpolator import GeoInterpolator

lons = np.arange(20).reshape((4, 5), order="F")
lats = np.arange(20).reshape((4, 5), order="C")
lines = np.array([2, 7, 12, 17]) / 5.0
cols = np.array([2, 7, 12, 17, 22])
hlines = np.arange(20) / 5.0
hcols = np.arange(24)
satint = GeoInterpolator((lons, lats), (lines, cols), (hlines, hcols),
                         chunk_size=10)
satint.fill_borders('x', 'y')