How to use the nansat.mappers.opendap.Opendap function in nansat

To help you get started, we’ve selected a few nansat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nansencenter / nansat / nansat / mappers / mapper_opendap_occci.py View on Github external
# Author:       Anton Korosov
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html
import json

import numpy as np

import pythesint as pti

from nansat.nsr import NSR
from nansat.mappers.opendap import Opendap

#https://rsg.pml.ac.uk/thredds/dodsC/CCI_ALL-v2.0-8DAY
#https://rsg.pml.ac.uk/thredds/dodsC/CCI_ALL-v2.0-MONTHLY
class Mapper(Opendap):
    ''' VRT with mapping of WKV for NCEP GFS '''
    baseURLs = ['https://rsg.pml.ac.uk/thredds/dodsC/CCI_ALL', 'https://www.oceancolour.org/thredds/dodsC/CCI_ALL']
    timeVarName = 'time'
    xName = 'lon'
    yName = 'lat'
    timeCalendarStart = '1970-01-01'

    srcDSProjection = NSR().wkt

    def __init__(self, fileName, gdalDataset, gdalMetadata,
                 date=None, ds=None, bands=None, cachedir=None,
                 **kwargs):
        ''' Create NCEP VRT
        Parameters:
            fileName : URL
            date : str
github nansencenter / nansat / nansat / mappers / mapper_opendap_mywave.py View on Github external
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html

from nansat.mappers.opendap import Opendap
from nansat.exceptions import WrongMapperError
from nansat.nsr import NSR
from netCDF4 import Dataset
from datetime import datetime
import numpy as np
import json
import pythesint as pti
import os


class Mapper(Opendap):

    baseURLs = ['http://thredds.met.no/thredds/dodsC/fou-hi/mywavewam4archive']
    timeVarName = 'time'
    xName = 'rlon'
    yName = 'rlat'
    timeCalendarStart = '1970-01-01'

    def __init__(self, filename, gdal_dataset, gdal_metadata, date=None,
                 ds=None, bands=None, cachedir=None, *args, **kwargs):

        self.test_mapper(filename)
        timestamp = date if date else self.get_date(filename)
        ds = Dataset(filename)
        try:
            self.srcDSProjection = NSR(ds.variables['projection_3'].proj4 +
                                       ' +to_meter=0.0174532925199 +wktext')
github nansencenter / nansat / nansat / mappers / opendap.py View on Github external
# assemble dimensions string
        dims = ''.join(['[%s]' % dim for dim in var_dimensions])
        meta_item = {
            'src': {'SourceFilename': '{url}?{var}.{var}{shape}'.format(url=url,
                                                                        var=var_name,
                                                                        shape=dims),
                    'SourceBand': 1},
            'dst': {'name': var_name,
                    'dataType': 6}
        }

        for attr in self.ds.variables[var_name].ncattrs():
            attr_key = Opendap._fix_encoding(attr)
            attr_val = self.ds.variables[var_name].getncattr(attr)
            if type(attr_val) in str_types:
                attr_val = Opendap._fix_encoding(attr_val)
            if attr_key in ['scale', 'scale_factor']:
                meta_item['src']['ScaleRatio'] = attr_val
            elif attr_key in ['offset', 'add_offset']:
                meta_item['src']['ScaleOffset'] = attr_val
            else:
                meta_item['dst'][attr_key] = attr_val

        return meta_item
github nansencenter / nansat / nansat / mappers / mapper_opendap_sentinel1.py View on Github external
def add_calibrated_nrcs(self, filename):
        layer_time_id, layer_date = Opendap.get_layer_datetime(None,
                self.convert_dstime_datetimes(self.get_dataset_time()))
        polarizations = [self.ds.polarisation[i:i+2] for i in range(0,len(self.ds.polarisation),2)]
        for pol in polarizations:
            dims = list(self.ds.variables['dn_%s' %pol].dimensions)
            dims[dims.index(self.timeVarName)] = layer_time_id
            src = [
                    self.get_metaitem(filename, 'Amplitude_%s' %pol, dims)['src'],
                    self.get_metaitem(filename, 'sigmaNought_%s' %pol, dims)['src']
                ]
            dst = {
                    'wkv': 'surface_backwards_scattering_coefficient_of_radar_wave',
                    'PixelFunctionType': 'Sentinel1Calibration',
                    'polarization': pol,
                    'suffix': pol,
                }
            self.create_band(src, dst)
github nansencenter / nansat / nansat / mappers / mapper_opendap_ostia.py View on Github external
# Author:       Artem Moiseev
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html

from nansat.mappers.opendap import Opendap
from nansat.nsr import NSR
import pythesint as pti
import os
from datetime import datetime
import numpy as np
import json
from netCDF4 import Dataset


class Mapper(Opendap):

    baseURLs = [
        'https://podaac-opendap.jpl.nasa.gov:443/opendap/allData/ghrsst/data/L4/GLOB/UKMO/OSTIA',
        'https://opendap.jpl.nasa.gov:443/opendap/OceanTemperature/ghrsst/data/L4/GLOB/UKMO/OSTIA'
    ]

    timeVarName = 'time'
    xName = 'lon'
    yName = 'lat'
    timeCalendarStart = '1981-01-01'
    srcDSProjection = NSR().wkt

    def __init__(self, filename, gdal_dataset, gdal_metadata, date=None,
                 ds=None, bands=None, cachedir=None, *args, **kwargs):

        self.test_mapper(filename)
github nansencenter / nansat / nansat / mappers / mapper_opendap_ostia.py View on Github external
# Author:       Artem Moiseev
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html

from nansat.mappers.opendap import Opendap
from nansat.nsr import NSR
import pythesint as pti
import os
from datetime import datetime
import numpy as np
import json
from netCDF4 import Dataset


class Mapper(Opendap):

    baseURLs = [
        'https://podaac-opendap.jpl.nasa.gov:443/opendap/allData/ghrsst/data/L4/GLOB/UKMO/OSTIA',
        'https://opendap.jpl.nasa.gov:443/opendap/OceanTemperature/ghrsst/data/L4/GLOB/UKMO/OSTIA'
    ]

    timeVarName = 'time'
    xName = 'lon'
    yName = 'lat'
    timeCalendarStart = '1981-01-01'
    srcDSProjection = NSR().wkt

    def __init__(self, filename, gdal_dataset, gdal_metadata, date=None,
                 ds=None, bands=None, cachedir=None, *args, **kwargs):

        self.test_mapper(filename)
github nansencenter / nansat / nansat / mappers / mapper_occci_online2.py View on Github external
# Name:         mapper_occci_online.py
# Purpose:      Nansat mapping for OC CCI data, stored online in THREDDS
# Author:       Anton Korosov
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html

import numpy as np

from nansat.nsr import NSR
from nansat.mappers.opendap import Opendap

class Mapper(Opendap):
    ''' VRT with mapping of WKV for NCEP GFS '''

    baseURL = 'https://rsg.pml.ac.uk/thredds/dodsC/CCI_ALL-v2.0'
    timeVarName = 'time'
    xName = 'lon'
    yName = 'lat'
    timeCalendarStart = '1970-01-01'

    srcDSProjection = NSR().wkt
    srcDSRasterXSize = 8640
    srcDSRasterYSize = 4320
    srcDSGeoTransform = (-179.97920227, 0.04167175, 0, 89.97915649, 0, -0.04166412)

    def __init__(self, fileName, gdalDataset, gdalMetadata,
                 date='2010-05-01', ds=None, bands=None, cachedir=None,
                 **kwargs):
github nansencenter / nansat / nansat / mappers / opendap.py View on Github external
bands: list
                list of src bands
            cachedir: str
        """
        if date is None:
            warnings.warn('Date is not specified! Will return the first layer. '
                          'Please add date="YYYY-MM-DD"')

        # TODO:  will be changed to vrt filename after init vrt
        self.filename = filename
        self.cachedir = cachedir
        self.ds = self.get_dataset(ds)

        ds_time = self.get_dataset_time()
        ds_times = self.convert_dstime_datetimes(ds_time)
        layer_time_id, layer_date = Opendap.get_layer_datetime(date, ds_times)

        if bands is None:
            var_names = self.get_geospatial_variable_names()
        else:
            var_names = bands
        # create VRT with correct lon/lat (geotransform)
        raster_x, raster_y = self.get_shape()
        geotransform = self.get_geotransform()
        self._init_from_dataset_params(int(raster_x), int(raster_y),
                                       geotransform, self.srcDSProjection)
        meta_dict = self.create_metadict(filename, var_names, layer_time_id)

        self.create_bands(meta_dict)

        # set time
        time_res_sec = self.get_time_coverage_resolution()
github nansencenter / nansat / nansat / mappers / mapper_opendap_norkyst800.py View on Github external
#               provided by MET Norway
# Author:       Artem Moiseev
# Licence:      This file is part of NANSAT. You can redistribute it or modify
#               under the terms of GNU General Public License, v.3
#               http://www.gnu.org/licenses/gpl-3.0.html

import os
import json
import pythesint as pti
import numpy as np
from datetime import datetime
from nansat.mappers.opendap import Opendap
from netCDF4 import Dataset


class Mapper(Opendap):

    baseURLs = ['http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/',
                'https://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/']

    timeVarName = 'time'
    xName = 'X'
    yName = 'Y'
    timeCalendarStart = '1970-01-01'

    def __init__(self, filename, gdal_dataset, gdal_metadata, date=None,
                 ds=None, bands=None, cachedir=None, *args, **kwargs):

        self.test_mapper(filename)
        ds = Dataset(filename)

        timestamp = date if date else self.get_date(filename)