def test_compare_reference_actual_job_2A4(timeindex, system_def, system_id): # UC 2A-4 timedict, timeind = timeindex param_dict = dict( compare="reference and actual performance", actual_data_parameters=dict( irradiance_type="poa", temperature_type="module", weather_granularity="system", performance_granularity="inverter", ), reference_data_parameters=dict( data_available="weather only", irradiance_type="standard", temperature_type="air", weather_granularity="inverter", ), time_parameters=timedict, system_id=system_id, ) job = models.Job(system_definition=system_def, parameters=param_dict) assert len(job._data_items) == 3 assert job._model_chain_method is None assert job._data_items[("/", "actual weather data")]._data_cols == [ "time", "poa_global", "poa_direct", "poa_diffuse", "module_temperature", ] assert job._data_items[("/inverters/0", "reference weather data")]._data_cols == [ "time", "ghi", "dni", "dhi", "temp_air", "wind_speed", ] assert job._data_items[("/inverters/0", "actual performance data")]._data_cols == [ "time", "performance", ] bad_params = param_dict.copy() bad_params["reference_data_parameters"][ "performance_granularity"] = "system" with pytest.raises(ValidationError): models.Job(system_definition=system_def, parameters=bad_params)
def test_compare_modeled_actual_job(timeindex, system_def, system_id): # UC 2C timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( compare="modeled and actual performance", irradiance_type="effective", temperature_type="cell", weather_granularity="system", performance_granularity="inverter", time_parameters=timedict, system_id=system_id, ), ) assert len(job._data_items) == 2 assert job._model_chain_method == "run_model_from_effective_irradiance" assert job._data_items[("/", "actual weather data")]._data_cols == [ "time", "effective_irradiance", "cell_temperature", ] assert job._data_items[("/inverters/0", "actual performance data")]._data_cols == [ "time", "performance", ]
def test_compare_reference_actual_job_2A3(system_def, system_id): job = models.Job( system_definition=system_def, parameters=dict( compare="monthly reference and actual performance", system_id=system_id, ), ) assert len(job._data_items) == 4 assert job._model_chain_method is None assert job._data_items[("/", "actual monthly weather data")]._data_cols == [ "month", "total_poa_insolation", "average_daytime_cell_temperature", ] assert job._data_items[("/", "reference monthly weather data")]._data_cols == [ "month", "total_poa_insolation", "average_daytime_cell_temperature", ] assert job._data_items[("/", "actual monthly performance data")]._data_cols == [ "month", "total_energy", ] assert job._data_items[( "/", "reference monthly performance data")]._data_cols == [ "month", "total_energy", ]
def test_calculate_weather_adjusted_pr_job(timeindex, system_def, system_id): # UC 2D timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( calculate="weather-adjusted performance ratio", irradiance_type="standard", temperature_type="air", weather_granularity="inverter", performance_granularity="system", time_parameters=timedict, system_id=system_id, ), ) assert len(job._data_items) == 2 assert job._model_chain_method == "run_model" assert job._data_items[("/inverters/0", "actual weather data")]._data_cols == [ "time", "ghi", "dni", "dhi", "temp_air", "wind_speed", ] assert job._data_items[("/", "actual performance data")]._data_cols == [ "time", "performance", ]
def test_calculate_modeled_job(timeindex, system_def, system_id): timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( calculate="modeled performance", irradiance_type="standard", temperature_type="module", weather_granularity="inverter", time_parameters=timedict, system_id=system_id, ), ) assert set(job._data_items.keys()) == { ("/inverters/0", models.JobDataTypeEnum.actual_weather), } assert job._model_chain_method == "run_model" assert job._data_items[("/inverters/0", "actual weather data")]._data_cols == [ "time", "ghi", "dni", "dhi", "module_temperature", ]
def test_calculate_reference_job(timeindex, system_def, system_id): timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( calculate="reference performance", irradiance_type="poa", temperature_type="module", weather_granularity="array", time_parameters=timedict, system_id=system_id, ), ) assert set(job._data_items.keys()) == { ("/inverters/0/arrays/0", models.JobDataTypeEnum.reference_weather), } assert job._model_chain_method == "run_model_from_poa" assert job._data_items[("/inverters/0/arrays/0", "reference weather data")]._data_cols == [ "time", "poa_global", "poa_direct", "poa_diffuse", "module_temperature", ]
def test_compare_reference_actual_job_2A1(timeindex, system_def, system_id): # UC 2A-1 timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( compare="reference and actual performance", actual_data_parameters=dict( irradiance_type="standard", temperature_type="air", weather_granularity="system", performance_granularity="system", ), reference_data_parameters=dict( data_available="weather, AC, and DC performance", irradiance_type="poa", temperature_type="module", weather_granularity="system", performance_granularity="system", ), time_parameters=timedict, system_id=system_id, ), ) assert len(job._data_items) == 5 assert job._model_chain_method is None assert job._data_items[("/", "actual weather data")]._data_cols == [ "time", "ghi", "dni", "dhi", "temp_air", "wind_speed", ] assert job._data_items[("/", "reference weather data")]._data_cols == [ "time", "poa_global", "poa_direct", "poa_diffuse", "module_temperature", ] assert job._data_items[("/", "actual performance data")]._data_cols == [ "time", "performance", ] assert job._data_items[("/", "reference performance data")]._data_cols == [ "time", "performance", ] assert job._data_items[("/", "reference DC performance data")]._data_cols == [ "time", "performance", ]
def test_lookup_compute_function(njp, system_def, exp, system_id, stored_job): njp["system_id"] = system_id njp["time_parameters"] = dict( start="2020-01-01T00:00:00+00:00", end="2020-12-31T23:59:59+00:00", step="15:00", timezone="UTC", ) job = models.Job(parameters=njp, system_definition=system_def) stored_job.definition = job assert compute.lookup_job_compute_function(stored_job) == exp
def test_compare_predicted_actual_job_2A2(timeindex, system_def, system_id): # UC 2A-2 timedict, timeind = timeindex job = models.Job( system_definition=system_def, parameters=dict( compare="predicted and actual performance", actual_data_parameters=dict( irradiance_type="poa", temperature_type="module", weather_granularity="array", performance_granularity="inverter", ), predicted_data_parameters=dict( data_available="weather and AC performance", irradiance_type="standard", temperature_type="air", weather_granularity="system", performance_granularity="system", ), time_parameters=timedict, system_id=system_id, ), ) assert len(job._data_items) == 4 assert job._model_chain_method is None assert job._data_items[ ("/inverters/0/arrays/0", "actual weather data") ]._data_cols == [ "time", "poa_global", "poa_direct", "poa_diffuse", "module_temperature", ] assert job._data_items[("/", "original weather data")]._data_cols == [ "time", "ghi", "dni", "dhi", "temp_air", "wind_speed", ] assert job._data_items[("/inverters/0", "actual performance data")]._data_cols == [ "time", "performance", ] assert job._data_items[("/", "predicted performance data")]._data_cols == [ "time", "performance", ]
def job_def(system_def, job_params): return models.Job(system_definition=system_def, parameters=job_params)