import numpy as np

l2 = {
'radarsat2': {
        'sensor': 'radarsat2',
        'table': 'cat_radarsat2',
        'fields': {
            'image_id':     'INT',
            'polarization': 'CHAR (4)',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/radarsat2/',
        },
    },

'radarsat2ice': {
        'sensor': 'radarsat2',
        'table': 'cat_radarsat2ice',
        'fields': {
            'image_id':     'INT',
            'polarization': 'CHAR (4)',
            'daily':        'INT',
            'weekly':       'INT',
            'monthly':      'INT',
        },
        'firstDate': '2012-11-01',
        'lastDate':  '',
        'region':    'POLYGON((-10 74, -10 83, 40 83, 40 74, -10 74))',
        'minInter':  0.1,
        'mask':      '%HH%HV%',
        'opts': {
            'name':    'process_ice',
            'oDir':    '/WebData/maires.nersc.no/public_html/catalog/radarsat2ice/',
            'step':    16,
            'threads': 4,
        },
    },

'radarsat2ice2': {
        'sensor': 'radarsat2',
        'table': 'cat_radarsat2ice2',
        'fields': {
            'image_id':     'INT',
            'polarization': 'CHAR (4)',
            'daily':        'INT',
            'weekly':       'INT',
            'monthly':      'INT',
        },
        'firstDate': '2014-07-01',
        'lastDate':  '',
        'region':    'POLYGON((-20 72, -20 82, 50 82, 50 72, -20 72))',
        'minInter':  0.1,
        'mask':      '%HH%HV%',
        'opts': {
            'name':    'process_ice',
            'oDir':    '/WebData/maires.nersc.no/public_html/catalog/radarsat2ice/',
            'step':    16,
            'threads': 6,
        },
    },


'modis_std': {
        'sensor': 'modis',
        'table': 'cat_modis_std',
        'fields': {
            'image_id': 'INT',
            'daily':    'INT',
            'weekly':   'INT',
            'monthly':  'INT',
        },
        'firstDate': '2013-02-01',
        'lastDate':  '',
        'region':    'POLYGON((-4 51, -4 66, 14 66, 14 51, -4 51))',
        'minInter':  0.3,
        'mask':      '%',
        'opts': {
            'name': 'process_std',
            'oDir': '/WebData/maires.nersc.no/public_html/catalog/modis_std/',
        },
    },


'modis_boreali': {
        'sensor': 'modis',
        'table': 'cat_modis_boreali',
        'fields': {
            'image_id': 'INT',
            'daily':    'INT',
            'weekly':   'INT',
            'monthly':  'INT',
        },
        'firstDate': '2013-02-01',
        'lastDate':  '',
        'region': 'POLYGON((-4 51, -4 66, 14 66, 14 51, -4 51))',
        'minInter': 0.3,
        'mask':      '%',
        'opts': {
            'name': 'process_boreali',
            'oDir': '/WebData/hab.nersc.no/NorthSea/l2/',
            'srs': '+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs',
            'ext': '-lle -4 51 14 66 -ts 980 1400',
            'prods': ['lmchl', 'lmtsm', 'lmdoc', 'lmmse'],
            'start': 5,
        },
    },

'modis_sst': {
        'sensor': 'modis_sst',
        'table': 'cat_modis_sst',
        'fields': {
            'image_id':  'INT',
            'clear':     'INT',
            'three_day': 'INT',
        },
        'firstDate': '2013-01-01',
        'lastDate':  '',
        'region': 'POLYGON((5 65, 30 65, 30 77, 5 77, 5 65))',
        'minInter': 0.1,
        'mask':      '%.L2_LAC_SST%',
        'opts': {
            'name': 'process_crop_sst',
            'oDir': '/WebData/maires.nersc.no/public_html/catalog/modis_sst/',
            'lonlim': [5, 30],
            'latlim': [65, 77],
        },
    },

'aster': {
        'sensor': 'aster',
        'table': 'cat_aster',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%.hdf',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/aster/',
        },
    },

'asar': {
        'sensor': 'asar',
        'table': 'cat_asar',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/asar/',
        },
    },

'asar_wind_barents': {
        'sensor': 'asar',
        'table': 'cat_asar_barents',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '2010-02-05',
        'lastDate':  '',
        'region':  'POLYGON((15 80, 67 80, 55 68, 25 68, 15 80))',
        'minInter':  0.1,
        'mask':      '%ASA_WSM%',
        'opts': {
            'name': 'process_wind_thredds',
            'threddsDir': '/WebData/maires.nersc.no/public_html/thredds/barents1km_asar_wind/barents1km_asar_wind_%s_%s.nc',
            'maskName' : 'mask',
            'domain': {
                        'srs': '+proj=stere +lat_0=74.5 +lon_0=40 +k_0=1.0 x_0=0 +y_0=0 +elleps=WGS84 +datum=WGS84 +units=m +no_defs',
                        'ext': '-te -550000 -670000 550000 670000 -tr 1000 1000',
                      },
            'bands' : {'U':     {'type' : '>i2',
                                 'scale' : 0.01,
                                 'offset': 0.0,
                                 'standard_name': 'eastward_wind',
                                 'long_name': 'Eastward wind velocity',
                                 'valid_range': [-3500, 3500],
                                 '_FillValue': np.int16(-10000),
                                 },
                       'V':     {'type' : '>i2',
                                 'scale':  0.01,
                                 'offset':0.0,
                                 'standard_name': 'northward_wind',
                                 'long_name': 'Northward wind velocity',
                                 'valid_range': [-3500, 3500],
                                 '_FillValue': np.int16(-10000),
                                 },
                       'mask':  {'type' : '>i1',
                                 'scale': 1.0,
                                 'offset': 0.0,
                                 'standard_name': 'northward_wind status_flag',
                                 'long_name': "Status flag for wind speed retrieval",
                                 'flag_meanings': "no_data clouds land nominal ",
                                 'flag_values' : np.byte([0, 1, 2, 64]),
                                 }
                       },
                'metadata': {
                                'acknowledgment': 'NORMAP NERSC, NORWEGIAN RESEARCH COUNCIL',
                                'creator_name': 'NERSC (Korosov A.)',
                                'comment': 'NORMAP data products from NERSC. References to description of algorithms could be found here: https://github.com/nansencenter/openwind',
                                'contributor_role': 'L2, L3 processing',
                                'creator_email': 'anton.korosov@nersc.no',
                                'Conventions': 'CF-1.5',
                                'contributor_name': 'NERSC (Yamakawa A.)',
                                'creator_url': 'http//www.nersc.no',
                                'cdm_data_type': 'Grid',
                                'date_issued': '2014-09-01',
                                'geospatial_vertical_max': '0',
                                'geospatial_lat_units': 'degrees_north',
                                'geospatial_lon_units': 'degrees_east',
                                'geospatial_lat_resolution': '0.008479111940298507',
                                'geospatial_lon_resolution': '0.05000000090909091',
                                'geospatial_vertical_min': '0',
                                'geospatial_vertical_resolution': '1',
                                'geospatial_vertical_positive': 'down',
                                'geospatial_vertical_units': 'm',
                                'GDAL': 'GDAL 2.0dev, released 2011/12/29',
                                'id': 'barents1km_asar_wind',
                                'institution': 'Nansen Environmental and Remote Sensing Centre',
                                'keywords': 'ATMOSPHERE > ATMOSPHERIC WINDS > SURFACE WINDS > WIND SPEED/WIND DIRECTION, OCEANS > OCEAN WINDS > SURFACE WINDS',
                                'keywords_vocabulary': 'GCMD Science Keywords',
                                'license': 'The data may be used and redistributed for free but is not intended for legal use, since it may contain inaccuracies. The data Contributordoes not make any warranty, express or implied, including warranties of merchantability and fitness for a particular purpose, or assumes any legal liability for the accuracy, completeness, or usefulness, of this information.',
                                'Metadata_Conventions': 'Unidata Dataset Discovery v1.0',
                                'Metadata_Link': 'http://normap.nersc.no/content/documentation-normap-products',
                                'naming_authority': 'nersc.no',
                                'publisher_name': 'NERSC',
                                'publisher_url': 'http//www.nersc.no',
                                'processing_level': '3',
                                'publisher_email': 'stein.sandven@nersc.no',
                                'project': 'NORMAP',
                                'standard_name_vocabulary': 'CF-1.4',
                                'summary': 'Wind Speed retrieved from ASAR backscatter and NCEP wind deirection using CMOD4',
                                'title': 'Barents Sea Surface Winds from ASAR',
                            },
                'rmMetadata' : ['colormap', 'minmax', 'wkv', 'time',
                                'sar_start_date', 'sar_stop_date'],

                'additionalMetadata' : [ 'sar_start_date', 'sar_stop_date',
                                        'date_created', 'date_modified',
                                        'geospatial_lat_min', 'geospatial_lat_max',
                                        'geospatial_lon_min', 'geospatial_lon_max',
                                        'time_coverage_start', 'time_coverage_end'],

                'timeName' : 'sar_start_date',
            }
        },

'asar_wind_blacksea': {
        'sensor': 'asar',
        'table': 'cat_asar_blacksea',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':  'POLYGON((28 46, 39 46, 42 41, 27 40, 28 46))',
        'minInter':  0.1,
        'mask':      '%ASA_WSM%',
        'opts': {
            'name': 'process_wind_thredds',
            'threddsDir': '/WebData/maires.nersc.no/public_html/catalog/asar_wind_bs/blacksea_wind_%s_%s.nc',
            'maskName' : 'mask',
            'domain': { 'srs': '+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs',
                        'ext': '-lle 27 40 42 46 -ts 1500 1000'
                      },
            'products': { 'U': {
                               'standard_name': 'eastward_wind',
                               'long_name': 'Eastward wind velocity',
                               'valid_range': [-3500, 3500],
                               '_FillValue': np.int16(-10000),
                              },
                          'V': {
                               'standard_name': 'northward_wind',
                               'long_name': 'Northward wind velocity',
                               'valid_range': [-3500, 3500],
                               '_FillValue': np.int16(-10000),
                              }
                         },
            'datatypes': {
                           'U': ['>i2', 0.0, 0.01],
                           'V': ['>i2', 0.0, 0.01],
                           'mask': '>i1',
                         },
            'metadata': { 'contact': 'anton.korosov@nersc.no',
                          'title': 'SAR wind',
                          'comment': 'SAR wind',
                          'sensor': 'ASAR',
                          'sar_start_date': None,
                          'sar_stop_date': None,
                        },
        },
    },

'asar_wind_mediterranean': {
        'sensor': 'asar',
        'table': 'cat_asar_mediterranean',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':  'POLYGON((2 44, 15 47, 37 37, 35 30, 19 30, -5 35, 2 44))',
        'minInter':  0.1,
        'mask':      '%ASA_WSM%',
        'opts': {
            'name': 'process_wind_thredds',
            'threddsDir': '/WebData/maires.nersc.no/public_html/catalog/asar_wind_med/mediterranean_wind_%s_%s.nc',
            'maskName' : 'mask',
            'domain': { 'srs': '+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs',
                        'ext': '-lle -5 30 37 47 -ts 2000 1000'
                      },
            'products': { 'U': {
                               'standard_name': 'eastward_wind',
                               'long_name': 'Eastward wind velocity',
                               'valid_range': [-3500, 3500],
                               '_FillValue': np.int16(-10000),
                              },
                          'V': {
                               'standard_name': 'northward_wind',
                               'long_name': 'Northward wind velocity',
                               'valid_range': [-3500, 3500],
                               '_FillValue': np.int16(-10000),
                              }
                         },
            'datatypes': {
                           'U': ['>i2', 0.0, 0.01],
                           'V': ['>i2', 0.0, 0.01],
                           'mask': '>i1',
                         },
            'metadata': { 'contact': 'anton.korosov@nersc.no',
                          'title': 'SAR wind',
                          'comment': 'SAR wind',
                          'sensor': 'ASAR',
                          'sar_start_date': None,
                          'sar_stop_date': None,
                        },
        },
    },

'meris': {
        'sensor': 'meris',
        'table': 'cat_meris',
        'fields': {
            'image_id': 'INT',
            'sensend' : 'DATE',
            'resolution' : 'CHAR (2)',
            'orbit'   : 'INT',
            'level'   : 'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/meris/',
        },
    },

'amsr2': {
        'sensor': 'amsr2',
        'table': 'cat_amsr2',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/amsr2/',
        },
    },

'oc': {
        'sensor': 'seawifs',
        'table': 'cat_oc_npp',
        'fields': {
            'image_id':     'INT',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':  '',
        'minInter':  0,
        'mask':      'npp_seawifs_%.mat%',
        'opts': {
            'name': 'process_thredds',
            'threddsDir': '/WebData/maires.nersc.no/public_html/catalog/oc',
            'ofileName' : 'arctic%dkm_%s_%04d%02d01_%04d%02d%02d.nc',
            'wkv':'npp', # 'npp','chl','tsm' and 'doc'
            'maskName' : 'mask',
            'dstDomain': {
                        'srs': 32661,
                        'ext': '-te -1000000 -1000000 5000000 5000000 -tr 4000 4000',
                      },
            'bandMetadata' :{'valid_range': None,
                             '_FillValue': np.float32(-10.0),
                             'units': None,
                             'type' : '>f4',
                            },
            'metadata': {
                'id': 'arctic4km_oceancolor',
                'naming_authority': 'nersc.no',
                'Metadata_Conventions': 'Unidata Dataset Discovery v1.0',
                'Metadata_Link': 'URL for full metadata record',
                'title': 'Arctic Net Primary Production',
                'summary': 'Ocean color products including Chlorophyll, Suspended Matter, Dissolved Organic Carbon and and Net Primary Production in the Arctic Ocean',
                'keywords_vocabulary': 'GCMD Science Keywords',
                'standard_name_vocabulary': 'CF-1.4',
                'Conventions': 'CF-1.4',
                'comment': 'NORMAP data products from NERSC. References to description of datasource and algorithms: SeaWIFS: http://oceancolor.gsfc.nasa.gov/SeaWiFS/; MODIS: http://modis.gsfc.nasa.gov/; BOREALI: doi:10.3390/a2010470; Behrenfeld: http://wiki.icess.ucsb.edu/measures/index.php/GSM; GSM: http://www.icess.ucsb.edu/OCisD/; OC3: http://0-oceancolor.gsfc.nasa.gov.iii-server.ualr.edu/SeaWiFS/TECH_REPORTS/PLVol11.pdf; Behrenfeld-1997: Behrenfeld, M., Falkowski, P. 1997.Limnol. Oceanogr. 42(1): 1-20; Behrenfeld-2005: doi:10.1029/2004GB002299; Mara: Marra, J., Ho, C., Trees, C. 2003',
                'geospatial_vertical_min': 0,
                'geospatial_vertical_max': 0,
                'geospatial_vertical_positive': 'down',
                'geospatial_lat_units': 'degrees_north',
                'geospatial_lon_units': 'degrees_east',
                'geospatial_vertical_units': 'm',
                'geospatial_vertical_resolution': 1,
                'acknowledgment': 'NORMAP NERSC, NORWEGIAN RESEARCH COUNCIL, MONARCH-A',
                'creator_email': 'anton.korosov@nersc.no',
                'creator_name': 'NERSC (Korosov A.)',
                'creator_url': 'http//www.nersc.no',
                'institution': 'Nansen Environmental and Remote Sensing Centre',
                'project': 'NORMAP',
                'contributor_name': 'NERSC (Dmitry Petrenko)',
                'contributor_role': 'L2/L3 processing',
                'publisher_email': 'anton.korosov@nersc.no',
                'publisher_name': 'NERSC',
                'publisher_url': 'http//www.nersc.no',
                'processing_level': 3,
                'license': 'The data may be used and redistributed for free but is not intended for legal use, since it may contain inaccuracies. The data Contributordoes not make any warranty, express or implied, including warranties of merchantability and fitness for a particular purpose, or assumes any legal liability for the accuracy, completeness, or usefulness, of this information.',
                'cdm_data_type': 'Grid',
                },
            'rmMetadata' : ['colormap', 'minmax', 'wkv', 'time'],

            'additionalMetadata' : ['date_created', 'date_modified', 'date_issued',
                                    'geospatial_lat_min', 'geospatial_lat_max',
                                    'geospatial_lon_min', 'geospatial_lon_max',
                                    'time_coverage_start', 'time_coverage_end',
                                    'history', 'geospatial_lat_resolution',
                                    'geospatial_lon_resolution', 'time_coverage_resolution',
                                    'valid_min', 'valid_max', 'keywords'],

            }
        },


'sentinel1': {
        'sensor': 'sentinel1',
        'table': 'cat_sentinel1',
        'fields': {
            'image_id':     'INT',
            'polarization': 'CHAR (4)',
        },
        'firstDate': '',
        'lastDate':  '',
        'region':    '',
        'minInter':  0,
        'mask':      '%',
        'opts': {
            'name': 'process_web',
            'mapDir': '/WebData/maires.nersc.no/public_html/catalog/sentinel1/',
        },
    },

}
