<jupyter_start><jupyter_text>Create inifiles Sophie<jupyter_code>import glob, os
import pandas as pd

from configparser import ConfigParser
from pathlib import Path<jupyter_output><empty_output><jupyter_text>Set Paths<jupyter_code>MODELDIR = Path('/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/')
FLUXDIR = Path('/lustre1/0/wtrcycle/users/jaerts/camels_wflow/sophie_BEP/')

flux_selection_file = 'fluxnet_toren_selectie_klein_Sophie_Jaren.csv'
config_file = "/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/global_05min/iniFileExample/setup_05min_non-natural.ini"<jupyter_output><empty_output><jupyter_text>Load FLUXNET selection DataFrame<jupyter_code>df = pd.read_csv(f'{FLUXDIR}/{flux_selection_file}', sep=';')
df = df.set_index('SITE_ID')
df<jupyter_output><empty_output><jupyter_text>Generate configuration files for each station<jupyter_code>for station_id, row in df.iterrows():
    
    start_year = row.Vanaf[:4]
    end_year = row.Tot[:4]
    
    config = ConfigParser()
    config.optionxform = str 
    config.read(config_file)

    config['globalOptions']['outputDir'] = '/data/output'
    config['globalOptions']['inputDir'] = '/data/input'

    config['globalOptions']['cloneMap'] = f'global_05min/cloneMaps/SophieBEP/{station_id.lower()}_05min.map'

    config['globalOptions']['startTime'] = f'{start_year}-01-01'
    config['globalOptions']['endTime']   = f'{end_year}-12-31'

    config['meteoOptions']['referenceETPotMethod'] = 'Hamon'

    config['meteoOptions']['precipitationNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_day_pr_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    config['meteoOptions']['temperatureNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_day_tas_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    config['meteoOptions']['refETPotFileNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_Eday_evspsblpot_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    
    config['meteoOptions']['precipitationVariableName'] = 'pr'
    config['meteoOptions']['temperatureVariableName'] = 'tas'
    config['meteoOptions']['referenceEPotVariableName'] = 'evspsblpot'
    
    config['meteoOptions']['precipitationConstant'] = '0.0'
    config['meteoOptions']['precipitationFactor'] = '1.0'
    config['meteoOptions']['temperatureConstant'] = '-273.15'
    config['meteoOptions']['temperatureFactor'] = '1.0'
    config['meteoOptions']['referenceEPotConstant'] = '0.0'
    config['meteoOptions']['referenceEPotFactor'] = '1.0'
    
    config['meteoDownscalingOptions']['downscalePrecipitation'] = 'True'
    config['meteoDownscalingOptions']['downscaleTemperature'] = 'True'
    config['meteoDownscalingOptions']['downscaleReferenceETPot'] = 'True'

    outfile = f'{MODELDIR}/{station_id.lower()}_05min_Hamon.ini'
    
    with open(outfile, 'w') as configfile:    # save
        config.write(configfile)
        print(configfile)
for station_id, row in df.iterrows():
    
    start_year = row.Vanaf[:4]
    end_year = row.Tot[:4]
    
    config = ConfigParser()
    config.optionxform = str 
    config.read(config_file)

    config['globalOptions']['outputDir'] = '/data/output'
    config['globalOptions']['inputDir'] = '/data/input'

    config['globalOptions']['cloneMap'] = f'global_05min/cloneMaps/SophieBEP/{station_id.lower()}_05min.map'

    config['globalOptions']['startTime'] = f'{start_year}-01-01'
    config['globalOptions']['endTime']   = f'{end_year}-12-31'

    config['meteoOptions']['referenceETPotMethod'] = 'Input'

    config['meteoOptions']['precipitationNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_day_pr_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    config['meteoOptions']['temperatureNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_day_tas_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    config['meteoOptions']['refETPotFileNC'] = f'global_05min/meteo/SophieBEP/pcrglobwb_OBS6_ERA5_reanaly_1_Eday_evspsblpot_{str((int(start_year) - 1))}-{end_year}_{station_id.lower()}.nc'
    
    config['meteoOptions']['precipitationVariableName'] = 'pr'
    config['meteoOptions']['temperatureVariableName'] = 'tas'
    config['meteoOptions']['referenceEPotVariableName'] = 'evspsblpot'
    
    config['meteoOptions']['precipitationConstant'] = '0.0'
    config['meteoOptions']['precipitationFactor'] = '1.0'
    config['meteoOptions']['temperatureConstant'] = '-273.15'
    config['meteoOptions']['temperatureFactor'] = '1.0'
    config['meteoOptions']['referenceEPotConstant'] = '0.0'
    config['meteoOptions']['referenceEPotFactor'] = '1.0'
    
    config['meteoDownscalingOptions']['downscalePrecipitation'] = 'True'
    config['meteoDownscalingOptions']['downscaleTemperature'] = 'True'
    config['meteoDownscalingOptions']['downscaleReferenceETPot'] = 'True'

    outfile = f'{MODELDIR}/{station_id.lower()}_05min_Input.ini'
    
    with open(outfile, 'w') as configfile:    # save
        config.write(configfile)
        print(configfile)<jupyter_output><_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/au-cpr_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/br-npw_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/cn-ha2_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/es-lgs_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/fr-pue_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/gf-guy_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/my-pso_05min_Input.ini' mode='w' encoding='UTF-8'>
<_io.TextIOWrapper name='/lustre1/0/wtrcycle/lorentz-workshop/pcr-globwb/input/nl-loo_05mi[...]
{'fraction_non_alphanumeric': 0.167400162999185, 'fraction_numerical': 0.0241238793806031, 'mean_word_length': 6.2103407755581665, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '546455', 'license': 'Apache-2.0', 'n_tokens_mistral': 2407, 'n_tokens_neox': 2308, 'n_words': 204, 'path': 'sophie_bsc/create_inifiles_Sophie.ipynb', 'repo_name': 'jeromaerts/teaching_supervision_code', 'size': '6135'}