Ejemplo n.º 1
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate u/v to a regular grid"""

        h_centroid, zeta_centroid = node_to_centroid(
            self.var_zeta, self.var_h, self.var_lon_nodal, self.var_lat_nodal,
            self.var_lon_centroid, self.var_lat_centroid, time_index)

        siglay_centroid = model_index.nc_file.variables[
            'siglay_centroid'][:, :]

        u_target_depth, v_target_depth = vertical_interpolation(
            self.var_u, self.var_v, h_centroid, zeta_centroid, siglay_centroid,
            self.num_nele, self.num_siglay, time_index, target_depth)

        return interp.interpolate_to_regular_grid(
            (u_target_depth, v_target_depth),
            self.var_lon_centroid,
            self.var_lat_centroid,
            model_index.var_x,
            model_index.var_y,
            interp_method=interp_method)
Ejemplo n.º 2
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate averaged, rotated u/v to a regular grid"""

        u_target_depth, v_target_depth = vertical_interpolation(
            self.var_u, self.var_v, self.var_s_rho, self.var_mask_rho,
            self.var_mask_u, self.var_mask_v, self.var_zeta, self.var_h,
            self.var_hc, self.var_cs_r, self.var_vtransform, self.num_eta,
            self.num_xi, self.num_sigma, time_index, target_depth)

        water_u, water_v, water_ang_rho, water_lat_rho, water_lon_rho = mask_land(
            u_target_depth, v_target_depth, self.var_ang_rho, self.var_lat_rho,
            self.var_lon_rho, self.var_mask_u, self.var_mask_v,
            self.var_mask_rho)

        u_rho, v_rho = average_uv2rho(water_u, water_v)

        rot_u_rho, rot_v_rho = rotate_uv2d(u_rho, v_rho, water_ang_rho)

        u_compressed, v_compressed, lat_compressed, lon_compressed = compress_variables(
            rot_u_rho, rot_v_rho, water_lat_rho, water_lon_rho)

        return interp.interpolate_to_regular_grid((u_compressed, v_compressed),
                                                  lon_compressed,
                                                  lat_compressed,
                                                  model_index.var_x,
                                                  model_index.var_y,
                                                  interp_method=interp_method)
Ejemplo n.º 3
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate u/v to a regular grid"""

        u_target_depth, v_target_depth = vertical_interpolation(
            self.var_u, self.var_v, self.var_mask, self.var_zeta,
            self.var_depth, self.var_sigma, self.num_sigma, self.num_ny,
            self.num_nx, time_index, target_depth)

        water_lat_rho = numpy.ma.masked_array(self.var_lat,
                                              numpy.logical_not(self.var_mask))
        water_lon_rho = numpy.ma.masked_array(self.var_lon,
                                              numpy.logical_not(self.var_mask))
        water_u = numpy.ma.masked_array(u_target_depth,
                                        numpy.logical_not(self.var_mask))
        water_v = numpy.ma.masked_array(v_target_depth,
                                        numpy.logical_not(self.var_mask))

        u_compressed = numpy.ma.compressed(water_u)
        v_compressed = numpy.ma.compressed(water_v)
        lat_compressed = numpy.ma.compressed(water_lat_rho)
        lon_compressed = numpy.ma.compressed(water_lon_rho)

        return interp.interpolate_to_regular_grid((u_compressed, v_compressed),
                                                  lon_compressed,
                                                  lat_compressed,
                                                  model_index.var_x,
                                                  model_index.var_y,
                                                  interp_method=interp_method)
Ejemplo n.º 4
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate u/v to a regular grid"""

        u_compressed, v_compressed, lat_compressed, lon_compressed = compress_variables(
            self.var_u, self.var_v, self.var_lat, self.var_lon, self.var_mask,
            time_index)

        return interp.interpolate_to_regular_grid((u_compressed, v_compressed),
                                                  lon_compressed,
                                                  lat_compressed,
                                                  model_index.var_x,
                                                  model_index.var_y,
                                                  interp_method=interp_method)
Ejemplo n.º 5
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate averaged, rotated u/v to a regular grid"""

        u_target_depth, v_target_depth = vertical_interpolation(
            self.var_u, self.var_v, self.var_s_rho, self.var_mask_rho,
            self.var_mask_u, self.var_mask_v, self.var_zeta, self.var_h,
            self.var_hc, self.var_cs_r, self.var_vtransform, self.num_eta,
            self.num_xi, self.num_sigma, time_index, target_depth)

        # Create masked arrays to mask land values
        water_u = numpy.ma.masked_array(u_target_depth,
                                        numpy.logical_not(self.var_mask_u))
        water_v = numpy.ma.masked_array(v_target_depth,
                                        numpy.logical_not(self.var_mask_v))

        # u/v masked values need to be set to 0 for averaging
        water_u = water_u.filled(0)
        water_v = water_v.filled(0)
        water_ang_rho = numpy.ma.masked_array(
            self.var_ang_rho, numpy.logical_not(self.var_mask_rho))
        water_lat_rho = numpy.ma.masked_array(
            self.var_lat_rho, numpy.logical_not(self.var_mask_rho))
        water_lon_rho = numpy.ma.masked_array(
            self.var_lon_rho, numpy.logical_not(self.var_mask_rho))

        u_rho, v_rho = average_uv2rho(water_u, water_v)

        rot_u_rho, rot_v_rho = rotate_uv2d(u_rho, v_rho, water_ang_rho)

        # u/v 1d arrays for interpolation
        u_compressed = numpy.ma.compressed(rot_u_rho)
        v_compressed = numpy.ma.compressed(rot_v_rho)
        lat_compressed = numpy.ma.compressed(water_lat_rho)
        lon_compressed = numpy.ma.compressed(water_lon_rho)

        return interp.interpolate_to_regular_grid((u_compressed, v_compressed),
                                                  lon_compressed,
                                                  lat_compressed,
                                                  model_index.var_x,
                                                  model_index.var_y,
                                                  interp_method=interp_method)
Ejemplo n.º 6
0
    def uv_to_regular_grid(self,
                           model_index,
                           time_index,
                           target_depth,
                           interp_method=interp.INTERP_METHOD_SCIPY):
        """Call grid processing functions and interpolate u/v to a regular grid"""

        u_single = self.var_u[time_index, 0, :, :]
        v_single = self.var_v[time_index, 0, :, :]

        water_lat = numpy.ma.masked_array(
            self.var_lat,
            self.var_mask,
        )
        water_lon = numpy.ma.masked_array(
            self.var_lon,
            self.var_mask,
        )
        water_u = numpy.ma.masked_array(
            u_single,
            self.var_mask,
        )
        water_v = numpy.ma.masked_array(
            v_single,
            self.var_mask,
        )

        u_compressed = numpy.ma.compressed(water_u)
        v_compressed = numpy.ma.compressed(water_v)
        lat_compressed = numpy.ma.compressed(water_lat)
        lon_compressed = numpy.ma.compressed(water_lon)

        return interp.interpolate_to_regular_grid((u_compressed, v_compressed),
                                                  lon_compressed,
                                                  lat_compressed,
                                                  model_index.var_x,
                                                  model_index.var_y,
                                                  interp_method=interp_method)