Exemplo n.º 1
0
def main():
    uv = iris.load(FILE_LOC)
    u = get_cube(uv, 0, 2)
    v = get_cube(uv, 0, 3)
    plt.ion()

    if SINGLE_TIME:
        print('Height: {}'.format(
            u[0, LEVEL_HEIGHT_INDEX].coord('level_height').points[0]))
        calc_uv_fft(u[-1, LEVEL_HEIGHT_INDEX].data, v[-1,
                                                      LEVEL_HEIGHT_INDEX].data)
    elif LOOP_TIME:
        print('Height: {}'.format(
            u[0, LEVEL_HEIGHT_INDEX].coord('level_height').points[0]))
        print('loop_time')
        for i in range(u.shape[0]):
            print(i)
            calc_uv_fft(u[i, LEVEL_HEIGHT_INDEX].data,
                        v[i, LEVEL_HEIGHT_INDEX].data,
                        pause=0.01)
    elif LOOP_HEIGHT:
        print('loop_height')
        for i in range(uv.shape[1]):
            print('Height: {}'.format(uv[0,
                                         i].coord('level_height').points[0]))
            calc_uv_fft(u[-1, i].data, v[-1, i].data, pause=0.01)
    elif LOOP_FILTER_SCALE:
        print('loop_filter_scale')
        print('Height: {}'.format(
            uv[0, LEVEL_HEIGHT_INDEX].coord('level_height').points[0]))
        for i in range(100):
            calc_uv_fft(u[-1, i].data, v[-1, i].data, scale=i, pause=0.01)

    return uv
Exemplo n.º 2
0
    def run(self):
        self.u = get_cube(self.cubes, 30, 201)
        self.v = get_cube(self.cubes, 30, 202)
        # Rem as soon as you hit cube.data it forces a load of all data into mem.
        # So the game is not to use cube.data until there is a small amount of data in the cube.
        logger.info('Cube shape: {}'.format(self.u.shape))
        self.cape = get_cube(self.cubes, 5, 233)

        if self.settings.LOC == 'tropics':
            kwargs = {'lat_slice': self.settings.TROPICS_SLICE}
        elif self.settings.LOC == 'NH':
            kwargs = {'lat_slice': self.settings.NH_TROPICS_SLICE}
        elif self.settings.LOC == 'SH':
            kwargs = {'lat_slice': self.settings.SH_TROPICS_SLICE}

        dates, u_samples, v_samples, lat, lon = _filter(
            self.settings,
            self.u,
            self.v,
            self.cape,
            filter_on=self.settings.FILTERS,
            **kwargs)
        pressure = self.u.coord('pressure').points
        columns = ['u{:.0f}_hPa'.format(p) for p in pressure] +\
                  ['v{:.0f}_hPa'.format(p) for p in pressure]
        self.df_filtered = pd.DataFrame(index=dates,
                                        columns=columns,
                                        data=np.concatenate(
                                            [u_samples, v_samples], axis=1))
        self.df_filtered['lat'] = lat
        self.df_filtered['lon'] = lon
 def run(self):
     self.output_cubes = {}
     for filename in self.task.filenames:
         cubes = self.cubes[filename]
         u = get_cube(cubes, 30, 201)
         v = get_cube(cubes, 30, 202)
         logger.info('Cube shape: {}'.format(u.shape))
         cape = get_cube(cubes, 5, 233)
         self.output_cubes[filename] = iris.cube.CubeList([u, v, cape])
def main():
    pc = iris.load(DATA_LOC + 'P1M/au197a.pc19880901.nc')
    u = get_cube(pc, 30, 201)
    v = get_cube(pc, 30, 202)
    cape = get_cube(pc, 5, 233)
    plot_example_profiles_hodographs()
    plot_gcm_for_schematic()
    plot_all_raw_profiles(u, v)
    plot_filtered_profiles(u, v, cape)
Exemplo n.º 5
0
    def __init__(self, mode, cubes):
        self.mode = mode
        self.cubes = cubes
        self.u = get_cube(self.cubes, 0, 2)
        coords = self.u.coords()
        # N.B. dims are time, height, lat, lon
        assert coords[2].name() == 'grid_latitude'
        assert coords[3].name() == 'grid_longitude'
        self.v = get_cube(self.cubes, 0, 3)
        self.w = get_cube(self.cubes, 0, 150)

        self.nx = self.u.shape[3]
        self.ny = self.u.shape[2]
        assert self.nx == self.ny
        self.half_nx = self.nx // 2

        if mode == 'uv':
            self.cube = self.u
        elif mode == 'w':
            self.cube = self.w
    def save(self, state=None, suite=None):
        # Pull out pressure and save.
        cubes = self.cubes[self.task.filenames[0]]
        u = get_cube(cubes, 30, 201)

        pressure = u.coord('pressure').points
        logger.info('Saving pressures: {}', pressure)
        pressure.dump(self.task.output_filenames[0])

        for filename, output_filename in zip(self.task.filenames, self.task.output_filenames[1:]):
            if not os.path.exists(output_filename):
                logger.info('Saving cubelist: {}', self.output_cubes[filename])
                logger.info('Saving to: {}', output_filename)
                iris.save(self.output_cubes[filename], output_filename, zlib=True)
            else:
                logger.info('File already exists: {}', output_filename)
Exemplo n.º 7
0
 def __init__(self, cubes, mode='uv'):
     self.cubes = cubes
     self.u = get_cube(self.cubes, 0, 2)
     self.v = get_cube(self.cubes, 0, 3)
     self.w = get_cube(self.cubes, 0, 2)