コード例 #1
0
    def build(self, variable, ftp):
        """Build initial dataset."""
        # We need to build these three files
        paths = self.get_paths(variable)

        # Retrieve rasters
        self.get_rasters(variable, ftp)

        # Reproject for area calculations
        for file in glob(os.path.join(self.tif_folder, "*tif")):
            self.reproject(file)

        # Convert originals to NetCDF file
        files = glob(os.path.join(self.tif_folder, variable + "*tif"))
        toNetCDF(tfiles=files, ncfiles=None, savepath=paths["original"],
                 index=variable, proj=4326, year1=1895, month1=1,
                 year2=TODAYS_DATE.year - 2, month2=12, wmode="w",
                 percentiles=False)

        # Convert projected files to NetCDF file
        files = glob(os.path.join(self.tif_folder, "proj_*tif"))
        toNetCDFAlbers(tfiles=files, ncfiles=None, savepath=paths["albers"],
                       index=variable, proj=PROJ, year1=1895, month1=1,
                       year2=TODAYS_DATE.year - 2, month2=12, wmode="w",
                       percentiles=False)

        # Create a percentile dataset
        toNetCDFPercentile(paths["original"], paths["percentile"])

        # Clear temp folder
        self._clear_tif()
コード例 #2
0
            del ds

        # Now, run toNetCDF using the file name dates.
        tfiles = glob(os.path.join(temp_folder, 'temp_*'))
        tfiles_proj = glob(os.path.join(temp_folder, 'proj_*'))
        nc_path = os.path.join(data_path, "data/droughtindices/netcdfs/",
                               index + ".nc")
        nc_path_proj = os.path.join(data_path,
                                    "data/droughtindices/netcdfs/albers",
                                    index + ".nc")
        toNetCDF(tfiles=tfiles,
                 ncfiles=None,
                 savepath=nc_path,
                 index=index,
                 proj=4326,
                 year1=1980,
                 month1=1,
                 year2=todays_date.year,
                 month2=12,
                 wmode='w',
                 percentiles=False)
        toNetCDFAlbers(tfiles=tfiles_proj,
                       ncfiles=None,
                       savepath=nc_path_proj,
                       index=index,
                       proj=proj,
                       year1=1980,
                       month1=1,
                       year2=todays_date.year,
                       month2=12,
                       wmode='w',
コード例 #3
0
        ncfiles = glob(os.path.join(local_path, 'temp_*[0-9]*.nc'))

        # This is the target file - wwdt acronyms differ
        nc_path = os.path.join(data_path, 'data/droughtindices/netcdfs/',
                               index_map[index] + '.nc')
        nc_path_proj = os.path.join(data_path,
                                    'data/droughtindices/netcdfs/albers',
                                    index_map[index] + '.nc')

        # This function smooshes everything into one netcdf file
        toNetCDF(tfiles,
                 ncfiles,
                 nc_path,
                 index,
                 proj=4326,
                 year1=1895,
                 month1=1,
                 year2=todays_date.year,
                 month2=todays_date.month,
                 wmode='w',
                 percentiles=False)

        # We are also including percentiles, so lets build another dataset
        pc_path = os.path.join(data_path,
                               'data/droughtindices/netcdfs/percentiles',
                               index_map[index] + '.nc')
        print("Calculating Percentiles...")
        toNetCDFPercentile(nc_path, pc_path)

        # Now create the alber's netcdf
        toNetCDFAlbers(tfiles_proj,
コード例 #4
0
            in_path = f
            out_path = os.path.join(tif_folder, 'proj_' + filename)
            ds = gdal.Warp(out_path, in_path, dstSRS=proj)
            ds = None

        # Now create the three netcdf files
        tfiles = glob(os.path.join(tif_folder, variable + '*'))
        tfiles_proj = glob(os.path.join(tif_folder, 'proj_*'))

        # Original
        toNetCDF(tfiles=tfiles,
                 ncfiles=None,
                 savepath=original_path,
                 index=variable,
                 proj=4326,
                 year1=1895,
                 month1=1,
                 year2=todays_date.year,
                 month2=12,
                 wmode='w',
                 percentiles=False)
        toNetCDFAlbers(tfiles=tfiles_proj,
                       ncfiles=None,
                       savepath=albers_path,
                       index=variable,
                       proj=proj,
                       year1=1895,
                       month1=1,
                       year2=todays_date.year,
                       month2=12,
                       wmode='w',