def _load_standard_coordinates(self, etc_path, coord_setting): """ """ print('Loading coordinates settings..') paths = utils.generate_filepaths(etc_path, pattern=coord_setting, endswith='.txt') settings = {} for p in paths: file_name = os.path.basename(p).replace('.txt', '') file_name = file_name.replace(coord_setting, 'array') settings[file_name] = np_txt_reader(p) self.set_attributes(self, **settings)
def _load_settings(self, etc_path): """ :param etc_path: str, local path to settings :return: Updates attributes of self """ print('Loading tiff settings..') paths = utils.generate_filepaths(etc_path, pattern='.tiff') settings = {} for p in paths: file_name = os.path.basename(p).replace('.tiff', '') settings[file_name], settings[file_name + '_meta'] = raster_reader( p, include_meta=True) self.set_attributes(self, **settings)
# writer='raster') if __name__ == "__main__": # Set path to data directory data_path = 'C:\\Temp\\baws_reanalys\\tiff_archive' # Create the Session object s = Session(data_path=data_path) # If we want to save data to a specific location, we set the export path here. # s.setting.set_export_directory(path=None) for year in range(2002, 2010): year = str(year) # Generate filepaths generator = generate_filepaths(s.data_path, pattern='cyano_daymap_' + year, endswith='.tiff', only_from_dir=True) # Loop through the file-generator and aggregate the data. # aggregation is a numpy 2d-array aggregation = raster_aggregation(generator) # Export the aggragation in a tiff file. # WARNING! tiff files only handles integer data with values <=100. # The benefit of tiff-files are the super compressed format s.export_data(data=aggregation, file_name='aggregation_%s.tiff' % year, writer='raster')
""" from bawsvis.utils import generate_filepaths from bawsvis.session import Session from bawsvis.data_handler import aggregation_annuals if __name__ == "__main__": # Set path to data directory data_path = 'C:\\Utveckling\\BAWS-vis\\bawsvis\\export' # Create the Session object s = Session(data_path=data_path) # Generate filepaths generator = generate_filepaths(s.data_path, pattern='Cumu_', endswith='.txt', only_from_dir=True) # Loop through the file-generator and aggregate the data. # aggregation is a numpy 2d-array aggregation = aggregation_annuals(generator, reader='text') # Export the aggragation in a tiff file. # WARNING! tiff files only handles integer data with values <=100. # The benefit of tiff-files are the super compressed format s.export_data(data=aggregation, file_name='period_aggregation.txt', writer='text')
from bawsvis.session import Session from bawsvis.data_handler import get_daily_stats, get_weekly_stats if __name__ == "__main__": # Set path to data directory data_path = '...\\Manuell_algtolkning' # Create the Session object s = Session(data_path=data_path) # If we want to save data to a specific location, we set the export path here. # s.setting.set_export_directory(path=None) # Generate filepaths (daily) generator = generate_filepaths(s.setting.export_directory, pattern='cyano_daymap_', endswith='.shp', only_from_dir=True) # Loop through the file-generator and aggregate the data. stats_daily = get_daily_stats(generator) # Generate filepaths (weekly) generator = generate_filepaths(s.data_path, pattern='cyano_weekmap_', endswith='.shp', only_from_dir=True) # Loop through the file-generator and aggregate the data. stats_weekly = get_weekly_stats(generator) stats = recursive_dict_update(stats_daily, stats_weekly)
from bawsvis.utils import generate_filepaths from bawsvis.session import Session from bawsvis.data_handler import raster_aggregation if __name__ == "__main__": # Set path to data directory data_path = 'E:\\Johannes_exjobb\\MODIS_data\\outdata\\attribute_data\\BAWS' # Create the Session object s = Session(data_path=data_path) # If we want to save data to a specific location, we set the export path here. # s.setting.set_export_directory(path=None) for year in range(2019, 2021): year = str(year) # Generate filepaths generator = generate_filepaths(s.data_path, pattern='BAWS_' + year, endswith='.txt', only_from_dir=False) # Loop through the file-generator and aggregate the data. # aggregation is a numpy 2d-array aggregation = raster_aggregation(generator, reader='text') # Export the aggragation s.export_data(data=aggregation, file_name='aggregation_%s.txt' % year, writer='text')