Skip to content

Commit

Permalink
[Bug] remove subtype times file (#87)
Browse files Browse the repository at this point in the history
* feat: Remove subtype_times_file

Reason for change:
When using subtype files with pregenerate _leaks, as site are
regenerated, the subtypes times are not carried over.

Resolution:
As site survey times can currently be set in the infrastructure file
on a per site basis AND it is desired to move this functionality over
to the subtype file, the subtype_times_file has been removed and the
functionality will be  reintroduced to the subtype file at a later date.

Effect(s) of change:
subtype_times_file removed

* fix: Removed references to subtype_times_file

Reason for change:
With the removal of the subtype times file, references to this removed
functionality must also be removed.

Resolution:
Removed all references in
end-to-end testing suite and the sample subtype_times_file in the
inputs.

Effect(s) of change:
All references to the Subtype times file are now removed.

* fix: Edit E2E expected output parameters

Reason for change:
E2E tests were failing because they had not been updated for
the latest parameter additions: n_init_days and n_init_leaks.

Resolution:
Adjusted the parameters in expected outputs to include n_init_days and
n_init_leaks.

Effect(s) of change:
E2E test can pass again now
  • Loading branch information
ThomasGalesloot committed Jul 27, 2023
1 parent 198614b commit 0acab25
Show file tree
Hide file tree
Showing 33 changed files with 794 additions and 825 deletions.
34 changes: 0 additions & 34 deletions LDAR_Sim/inputs/subtype_times.csv

This file was deleted.

1 change: 0 additions & 1 deletion LDAR_Sim/src/default_parameters/p_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ weather_file: "weather_alberta.nc"
weather_is_hourly: True # True/False
infrastructure_file: "facilities_alberta.csv"
site_samples: 500
subtype_times_file: "_placeholder_str_"
subtype_file: "_placeholder_str_"
consider_weather: False # True/False
repair_delay:
Expand Down
10 changes: 0 additions & 10 deletions LDAR_Sim/src/initialization/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ def generate_sites(program, in_dir, pregen_leaks):
# even if n_samples is None, the sample function is still used to shuffle
sites = random.sample(sites, n_samples)

# Get subtype Times
if program['subtype_times_file'] is not None:
subtypes_times_f = pd.read_csv(
in_dir / program['subtype_times_file'],
index_col='subtype_code')
subtypes_times = subtypes_times_f.to_dict('index')
for site in sites:
subtype_time = subtypes_times[site['subtype_code']]
site.update(subtype_time)

# Get leaks from file
if program['emissions']['leak_file'] is not None:
program['emissions']['empirical_leaks'] = np.array(
Expand Down
9 changes: 1 addition & 8 deletions LDAR_Sim/src/ldar_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,7 @@ def __init__(self, global_params, state, params, timeseries):
state['sites'] = random.sample(
state['sites'],
params['site_samples'])
if params['subtype_times_file'] is not None:
subtype_times_file = pd.read_csv(
params['input_directory'] / params['subtype_times_file'])
cols_to_add = subtype_times_file.columns[1:].tolist()
for col in cols_to_add:
for site in state['sites']:
site[col] = subtype_times_file.loc[subtype_times_file['subtype_code'] ==
int(site['subtype_code']), col].iloc[0]

# Shuffle all the entries to randomize order for identical 't_Since_last_LDAR' values
random.shuffle(state['sites'])

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{'P_air': {'version': '2.0', 'parameter_level': 'program', 'methods': {'airH': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 100, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': False, 'label': 'airH', 'max_workday': 8, 'measurement_scale': 'site', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'default', 'QE': 0.0, 'MDL': [5.55], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [5]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': 4, 'time': 5}, 'OGI_FU': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 500, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': True, 'label': 'OGI_FU', 'max_workday': 8, 'measurement_scale': 'component', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'OGI_camera_zim', 'QE': 0.0, 'MDL': [0.24, 0.39], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [30]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': None, 'time': 120}}, 'method_labels': ['airH', 'OGI_FU'], 'program_name': 'P_air', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_times_file': None, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31]}, 'P_none': {'version': '2.0', 'parameter_level': 'program', 'methods': {}, 'method_labels': [], 'program_name': 'P_none', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_times_file': None, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31], 'subtypes': {0: {'dist_type': 'lognorm', 'dist_scale': 0.1669601696670407, 'dist_shape': [2.17], 'leak_rate_units': ['kilogram', 'hour'], 'leak_rate_dist': <scipy.stats._distn_infrastructure.rv_continuous_frozen object at 0x0000020CCE025990>}}}, 'P_OGI': {'version': '2.0', 'parameter_level': 'program', 'methods': {'OGI': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 500, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': False, 'label': 'OGI', 'max_workday': 8, 'measurement_scale': 'component', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'OGI_camera_zim', 'QE': 0.0, 'MDL': [0.24, 0.39], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [30]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': 4, 'time': 120}}, 'method_labels': ['OGI'], 'program_name': 'P_OGI', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_times_file': None, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31]}}
{'P_air': {'version': '2.0', 'parameter_level': 'program', 'methods': {'airH': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 100, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': False, 'label': 'airH', 'max_workday': 8, 'measurement_scale': 'site', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'default', 'QE': 0.0, 'MDL': [5.55], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [5]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': 4, 'time': 5}, 'OGI_FU': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 500, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': True, 'label': 'OGI_FU', 'max_workday': 8, 'measurement_scale': 'component', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'OGI_camera_zim', 'QE': 0.0, 'MDL': [0.24, 0.39], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [30]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': None, 'time': 120}}, 'method_labels': ['airH', 'OGI_FU'], 'program_name': 'P_air', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31]}, 'P_none': {'version': '2.0', 'parameter_level': 'program', 'methods': {}, 'method_labels': [], 'program_name': 'P_none', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31], 'subtypes': {0: {'dist_type': 'lognorm', 'dist_scale': 0.1669601696670407, 'dist_shape': [2.17], 'leak_rate_units': ['kilogram', 'hour'], 'leak_rate_dist': <scipy.stats._distn_infrastructure.rv_continuous_frozen object at 0x0000020CCE025990>}}}, 'P_OGI': {'version': '2.0', 'parameter_level': 'program', 'methods': {'OGI': {'consider_daylight': False, 'cost': {'per_day': 0, 'per_hour': 0, 'per_site': 500, 'upfront': 0}, 'coverage': {'spatial': 1.0, 'temporal': 1.0}, 'deployment_type': 'mobile', 'follow_up': {'preferred_method': None, 'delay': 0, 'instant_threshold': None, 'instant_threshold_type': 'absolute', 'interaction_priority': 'threshold', 'min_followups': [], 'min_followup_type': 'annual', 'min_followup_days_to_end': 0, 'proportion': 1.0, 'redundancy_filter': 'recent', 'threshold': 0.0, 'threshold_type': 'absolute'}, 'is_follow_up': False, 'label': 'OGI', 'max_workday': 8, 'measurement_scale': 'component', 'n_crews': None, 'parameter_level': 'method', 'reporting_delay': 2, 'scheduling': {'deployment_months': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'deployment_years': [], 'LDAR_crew_init_location': [-114.062, 51.044], 'home_bases_files': 'Airport_AB_Coordinates.csv', 'route_planning': False, 'travel_speeds': [], 'min_time_bt_surveys': None}, 'sensor': {'type': 'OGI_camera_zim', 'QE': 0.0, 'MDL': [0.24, 0.39], 'mod_loc': None}, 't_bw_sites': {'file': None, 'vals': [30]}, 'weather_envs': {'precip': [0.0, 0.5], 'temp': [-40.0, 40.0], 'wind': [0.0, 10.0]}, 'version': '2.0', 'RS': 4, 'time': 120}}, 'method_labels': ['OGI'], 'program_name': 'P_OGI', 'weather_file': 'ERA5_2017_2019_Perm.nc', 'weather_is_hourly': True, 'infrastructure_file': 'facilities_Perm.csv', 'site_samples': 50, 'subtype_file': None, 'consider_weather': False, 'repair_delay': {'type': 'default', 'val': [14.0]}, 'emissions': {'consider_venting': True, 'leak_dist_params': [-1.79, 2.17], 'leak_dist_type': 'lognorm', 'leak_file': None, 'leak_file_use': 'sample', 'LPR': 0.0065, 'max_leak_rate': 100000, 'subtype_leak_dist_file': None, 'units': ['kilogram', 'hour']}, 'NRd': 365, 'economics': {'carbon_price_tonnesCO2e': 40.0, 'cost_CCUS': 20.0, 'GWP_CH4': 28.0, 'sale_price_natgas': 3.0, 'repair_costs': {'vals': [200], 'file': None}, 'verification_cost': 0}, 'start_date': [2017, 1, 1], 'end_date': [2021, 12, 31]}}
2023-06-05 12:36:07.100267

0 comments on commit 0acab25

Please sign in to comment.