Example #1
0
        def register_4D_variable(self, units, variable, varname, gridded_int):
            """Registers a 4d interpolator with 4d signature"""

            #determine which file the variable came from
            for i in range(
                    len(self.patterns) - 1, -1,
                    -1):  #go in reverse to account for overwritten variables
                if varname in self.varfiles[str(i)]:
                    time = getattr(self, '_time' + str(i))
                    lat = getattr(self, '_lat' +
                                  str(i))  #get the correct coordinates
                    lon = getattr(self, '_lon' + str(i))
                    radius = getattr(self, '_radius' + str(i))
                    #print(varname, self.patterns[i])
                    break
                else:
                    print(varname, self.patterns[i])

            #define and register the interpolators
            xvec_dependencies = {
                'time': 'hr',
                'lon': 'deg',
                'lat': 'deg',
                'radius': 'R_E'
            }
            self = regdef_4D_interpolators(self, units, variable, time, lon,
                                           lat, radius, varname,
                                           xvec_dependencies, gridded_int)
            return
Example #2
0
    def register_4D_variable(self, units, variable, varname, file_type,
                             gridded_int):
        """Registers a 4d interpolator with 4d signature"""

        #determine coordinate variables by file_type
        if file_type == 'density':
            t, z, lat, lon = self._time, self._ilev, self._lat, self._lon
            xvec_dependencies = {
                'time': 'hr',
                'ilev': 'm/m',
                'lat': 'deg',
                'lon': 'deg'
            }
        if file_type == 'height':
            t, z, lat, lon = self._time, self._height, self._lat_height, self._lon_height
            xvec_dependencies = {
                'time': 'hr',
                'height': 'km',
                'lat': 'deg',
                'lon': 'deg'
            }
        if file_type == 'neutral':
            t, z, lat, lon = self._time, self._ilev_neutral, self._lat_neutral, self._lon_neutral
            xvec_dependencies = {
                'time': 'hr',
                'ilev': 'm/m',
                'lat': 'deg',
                'lon': 'deg'
            }

        #define and register the interpolators
        self = RU.regdef_4D_interpolators(self, units, variable, t, z, lat,
                                          lon, varname, xvec_dependencies,
                                          gridded_int)
        return
Example #3
0
        def register_4D_variable(self, units, variable, varname, gridded_int):
            """Registers a 4d interpolator with 4d signature"""

            #define and register the fast interpolator
            xvec_dependencies = {
                'time': 'hr',
                'lon': 'deg',
                'lat': 'deg',
                'radius': 'R_E'
            }
            self = regdef_4D_interpolators(self, units, variable, self._time,
                                           self._lon, self._lat, self._radius,
                                           varname, xvec_dependencies,
                                           gridded_int)
            return
Example #4
0
    def register_4D_variable(self, units, variable, varname, gridded_int):
        """Registers a 4d interpolator with 4d signature"""

        ####  Get the correct coordinates
        if varname in self.ilev_list:
            vert_coord = self._ilev
            lat, lon = self._lat, self._lon
            xvec_dependencies = {
                'time': 'hr',
                'ilev': 'm/m',
                'lat': 'deg',
                'lon': 'deg'
            }
        elif varname in self.lev_list:
            vert_coord = self._lev
            lat, lon = self._lat, self._lon
            xvec_dependencies = {
                'time': 'hr',
                'lev': 'm/m',
                'lat': 'deg',
                'lon': 'deg'
            }
        elif varname in self.imlev_list:
            vert_coord = self._imlev
            lat, lon = self._mlat, self._mlon
            xvec_dependencies = {
                'time': 'hr',
                'imlev': 'm/m',
                'mlat': 'deg',
                'mlon': 'deg'
            }

        #### define and register the interpolators
        if 'lat' in xvec_dependencies.keys():
            wrapped_data = self.wrap_4Dlatlon(varname, variable)
        else:
            wrapped_data = variable  #no wrapping needed for mlat and mlon
        self = RU.regdef_4D_interpolators(self, units, wrapped_data,
                                          self._time, vert_coord, lat, lon,
                                          varname, xvec_dependencies,
                                          gridded_int)
        return
Example #5
0
        def register_4D_variable(self, units, variable, varname, gridded_int):
            """Registers a 4d interpolator with 4d signature"""

            #determine coordinate variables by coord list
            coord_list = [value[5][-1] for key, value in model_varnames.items() \
                           if value[0]==varname][0]
            if 'ilev1' in coord_list:
                lon, lat, z = self._lon1, self._lat1, self._ilev1
                xvec_dependencies = {
                    'time': 'hr',
                    'lon': 'deg',
                    'lat': 'deg',
                    'ilev1': 'm/m'
                }
            if 'ilev' in coord_list:
                lon, lat, z = self._lon0, self._lat0, self._ilev
                xvec_dependencies = {
                    'time': 'hr',
                    'lon': 'deg',
                    'lat': 'deg',
                    'ilev': 'm/m'
                }
            if 'radius' in coord_list:
                lon, lat, z = self._lon, self._lat, self._radius
                xvec_dependencies = {
                    'time': 'hr',
                    'lon': 'deg',
                    'lat': 'deg',
                    'radius': 'R_E'
                }

            #define and register the interpolators
            self = regdef_4D_interpolators(self, units, variable, self._time,
                                           lon, lat, z, varname,
                                           xvec_dependencies, gridded_int)
            return
Example #6
0
        def register_4D_variable(self, units, variable, varname, gridded_int):
            """Registers a 4d interpolator with 4d signature"""

            ####  Get the correct coordinates
            if varname in self.ilev1_list:
                h = self._ilev1
                coord_lat, coord_lon = self._lat, self._lon
                xvec_dependencies = {
                    'time': 'hr',
                    'lon': 'deg',
                    'lat': 'deg',
                    'ilev1': 'm/m'
                }
            elif varname in self.ilev_list:
                h = self._ilev
                coord_lat, coord_lon = self._lat, self._lon
                xvec_dependencies = {
                    'time': 'hr',
                    'lon': 'deg',
                    'lat': 'deg',
                    'ilev': 'm/m'
                }
            elif varname in self.milev_list:
                h = self._milev
                coord_lat, coord_lon = self._mlat, self._mlon
                xvec_dependencies = {
                    'time': 'hr',
                    'mlon': 'deg',
                    'mlat': 'deg',
                    'milev': 'm/m'
                }
            else:
                print(varname, 'error')

            #### define and register the interpolators
            if 'lat' in xvec_dependencies.keys():
                wrapped_data = self.wrap_4Dlatlon(varname, variable)
            else:
                top_shape = list(variable[:, :, :, -1].shape)
                top_size = top_shape[0] * top_shape[1] * top_shape[
                    2]  #3D array
                idx_top = where(variable[:, :, :, -1] > 1e+35)[0]
                tmp_data = variable
                while top_size == len(
                        idx_top):  #then top row is undefined! Remove it.
                    print(
                        f'All values at max milev are 1e+36 for {varname}. Slicing off top array.'
                    )
                    if self._milev.shape[0] == len(tmp_data[0, 0, 0, :]):
                        self._milev = self._milev[0:-1]
                    tmp_data = tmp_data[:, :, :, 0:-1]
                    top_shape = list(tmp_data[:, :, :, -1].shape)
                    top_size = top_shape[0] * top_shape[1] * top_shape[
                        2]  #3D array
                    idx_top = where(tmp_data[:, :, :, -1] > 1e+35)[0]
                wrapped_data = tmp_data
                h = self._milev
            self = regdef_4D_interpolators(self, units, wrapped_data,
                                           self._time, coord_lon, coord_lat, h,
                                           varname, xvec_dependencies,
                                           gridded_int)
            return