def main():

    main_dir = Path(r'P:\Synchronize\IWS\Testings\fourtrans_practice\multisite_phs_spec_corr\5min\v7')
    os.chdir(main_dir)

    path_to_shp = r'P:\Synchronize\IWS\QGIS_Neckar\raster\taudem_out_spate_rockenau\watersheds_all.shp'

    label_field = r'DN'

    var = 'orig'
    suff = '__RR1D_RTsum'

    path_to_ras = f'{var}/{var}{suff}.nc'

    nc_x_crds_label = 'X'
    nc_y_crds_label = 'Y'
    nc_variable_labels = ['OK']
    nc_time_label = 'time'

    overwrite_flag = True

    path_to_output = Path(f'{var}/{var}{suff}.h5')

    if overwrite_flag and path_to_output.exists():
        os.remove(path_to_output)

    Ext = Extract(True)

    res = Ext.extract_from_netCDF(
        path_to_shp,
        label_field,
        path_to_ras,
        path_to_output,
        nc_x_crds_label,
        nc_y_crds_label,
        nc_variable_labels,
        nc_time_label)

    print('res:', res)

    return
def main():

    main_dir = Path(r'P:\Synchronize\IWS\Testings\fourtrans_practice\multisite_phs_spec_corr\temperature_kriging')
    os.chdir(main_dir)

    path_to_shp = r'P:\Synchronize\IWS\QGIS_Neckar\raster\taudem_out_spate_rockenau\watersheds.shp'

    label_field = r'DN'

    path_to_ras = r'kriging_1km_mag.nc'
    input_ras_type = 'nc'

#     path_to_ras = r'P:\Synchronize\IWS\Colleagues_Students\Mischa\lulc_geohyd_ratio_rasters\lower_de_gauss_z3_1km_hydrogeol_einheit_nr_hydmod_lulc_ratios.tif'
#     input_ras_type = 'gtiff'

    nc_x_crds_label = 'X'
    nc_y_crds_label = 'Y'
    nc_variable_labels = ['OK']
    nc_time_label = 'freq'

    src_epsg = None
    dst_epsg = None

#     src_epsg = 4326
#     dst_epsg = 31467

#     main_dir = Path(r'P:\Downloads\spinterp_2d_nc_crds_test')
#     os.chdir(main_dir)
#
#     path_to_shp = r'01Small.shp'
#
#     label_field = r'Id'
#
#     path_to_ras = r'pr_SAM-44_ICHEC-EC-EARTH_historical_r12i1p1_SMHI-RCA4_v3_day_19810101-19851231.nc'
#     input_ras_type = 'nc'
#
#     nc_x_crds_label = 'lon'
#     nc_y_crds_label = 'lat'
#     nc_variable_labels = ['pr']
#     nc_time_label = 'time'

    path_to_output = Path(r'neckar_6cats_temp_1991_1991.h5')
#     path_to_output = 'lower_de_gauss_z3_1km_hydrogeol_einheit_nr_hydmod_lulc_ratios.h5'

    Ext = Extract(True)

    res = None

    if input_ras_type == 'gtiff':
        res = Ext.extract_from_geotiff(
            path_to_shp,
            label_field,
            path_to_ras,
            path_to_output,
            src_epsg,
            dst_epsg)

    elif input_ras_type == 'nc':
        res = Ext.extract_from_netCDF(
            path_to_shp,
            label_field,
            path_to_ras,
            path_to_output,
            nc_x_crds_label,
            nc_y_crds_label,
            nc_variable_labels,
            nc_time_label,
            src_epsg,
            dst_epsg)

    else:
        raise NotImplementedError

    print('\n')
    print('res:', res)

    return
def main():

    main_dir = Path(r'P:\Downloads\spinterp_nc_gtiff_test')
    os.chdir(main_dir)

    path_to_shp = r'watersheds.shp'

    label_field = r'DN'

    path_to_ras = r'tem_spinterp.nc'
    input_ras_type = 'nc'

#     path_to_ras = r'lower_de_gauss_z3_2km_atkis_19_extended_hydmod_lulc_ratios.tif'
#     input_ras_type = 'gtiff'

    nc_x_crds_label = 'X'
    nc_y_crds_label = 'Y'
    nc_variable_labels = ['OK', 'SK']
    nc_time_label = 'time'

#     main_dir = Path(r'P:\Downloads\spinterp_2d_nc_crds_test')
#     os.chdir(main_dir)
#
#     path_to_shp = r'01Small.shp'
#
#     label_field = r'Id'
#
#     path_to_ras = r'pr_SAM-44_ICHEC-EC-EARTH_historical_r12i1p1_SMHI-RCA4_v3_day_19810101-19851231.nc'
#     input_ras_type = 'nc'
#
#     nc_x_crds_label = 'lon'
#     nc_y_crds_label = 'lat'
#     nc_variable_labels = ['pr']
#     nc_time_label = 'time'

    path_to_output = 'test.h5'

    Ext = Extract(True)

    res = None

    if input_ras_type == 'gtiff':
        res = Ext.extract_from_geotiff(
            path_to_shp, label_field, path_to_ras, path_to_output)

    elif input_ras_type == 'nc':

        res = Ext.extract_from_netCDF(
            path_to_shp,
            label_field,
            path_to_ras,
            path_to_output,
            nc_x_crds_label,
            nc_y_crds_label,
            nc_variable_labels,
            nc_time_label)

    else:
        raise NotImplementedError

    print(res)

    return