nansencenter / nansat

Scientist friendly Python toolbox for processing 2D satellite Earth observation data.
http://nansat.readthedocs.io
GNU General Public License v3.0
182 stars 66 forks source link

Isssue475 met hfr mapper #477

Closed korvinos closed 4 years ago

korvinos commented 4 years ago
korvinos commented 4 years ago

The mapper supports data from two HFRs TORU: https://thredds.met.no/thredds/fileServer/remotesensinghfradar/2017/11/28/TORU/RDLm_TORU_2017_11_28.nc FRUH: https://thredds.met.no/thredds/catalog/remotesensinghfradar/2017/11/28/FRUH/catalog.html?dataset=remotesensinghfradar/2017/11/28/FRUH/RDLm_FRUH_2017_11_28.nc

akorosov commented 4 years ago

@korvinos , both files failed:

In [5]: n = Nansat('RDLm_FRUH_2017_11_28.nc', mapper='metno_hfr')                                                                           
---------------------------------------------------------------------------
WrongMapperError                          Traceback (most recent call last)
<ipython-input-5-f3367fe14b0a> in <module>
----> 1 n = Nansat('RDLm_FRUH_2017_11_28.nc', mapper='metno_hfr')

/src/nansat/nansat.py in __init__(self, filename, mapper, log_level, **kwargs)
    157         self._init_empty(filename, log_level)
    158         # Create VRT object with mapping of variables
--> 159         self.vrt = self._get_mapper(mapper, **kwargs)
    160 
    161     def __getitem__(self, band_id):

/src/nansat/nansat.py in _get_mapper(self, mappername, **kwargs)
   1140 
   1141             # create VRT using the selected mapper
-> 1142             tmp_vrt = nansatMappers[mappername](self.filename, gdal_dataset, metadata, **kwargs)
   1143             self.mapper = mappername.replace('mapper_', '')
   1144         else:

/src/nansat/mappers/mapper_metno_hfr.py in __init__(self, filename, gdal_dataset, gdal_metadata, GCP_COUNT, timestamp, **kwargs)
     27         filename_name = os.path.split(filename)[-1].split('.')[0]
     28         if not filename_name.startswith('RDLm_TORU'):
---> 29             raise WrongMapperError
     30 
     31         # Import NetCDF4 dataset

WrongMapperError: 

In [7]: n = Nansat('RDLm_TORU_2017_11_28.nc', mapper='metno_hfr')                                                                           
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-7851b1b7b97e> in <module>
----> 1 n = Nansat('RDLm_TORU_2017_11_28.nc', mapper='metno_hfr')

/src/nansat/nansat.py in __init__(self, filename, mapper, log_level, **kwargs)
    157         self._init_empty(filename, log_level)
    158         # Create VRT object with mapping of variables
--> 159         self.vrt = self._get_mapper(mapper, **kwargs)
    160 
    161     def __getitem__(self, band_id):

/src/nansat/nansat.py in _get_mapper(self, mappername, **kwargs)
   1140 
   1141             # create VRT using the selected mapper
-> 1142             tmp_vrt = nansatMappers[mappername](self.filename, gdal_dataset, metadata, **kwargs)
   1143             self.mapper = mappername.replace('mapper_', '')
   1144         else:

/src/nansat/mappers/mapper_metno_hfr.py in __init__(self, filename, gdal_dataset, gdal_metadata, GCP_COUNT, timestamp, **kwargs)
     32         nc_dataset = Dataset(filename)
     33         # Get x grid and y grid
---> 34         x_grd, y_grd = self.create_linear_grid(nc_dataset['x'][:], nc_dataset['y'][:])
     35         raster_x_size, raster_y_size = x_grd.shape
     36         # Define projection (depending on the HFR)

/src/nansat/mappers/mapper_metno_hfr.py in create_linear_grid(self, x, y)
    113 
    114     def create_linear_grid(self, x, y):
--> 115         x_grd, y_grd = np.meshgrid(np.arange(x.min(), x.max(), self.GRID_PX_SIZE),
    116                                    np.arange(y.max(), y.min(), self.GRID_PX_SIZE * -1))
    117         return x_grd, y_grd

AttributeError: 'Mapper' object has no attribute 'GRID_PX_SIZE'

Can you double check again?