def main(): session = AmunSession() # Get the first valuation and duplicate it valuations = session.get_valuations() valuation_id = valuations[0]["id"] new_valuation_id = copy_valuation(valuation_id, session)
def show_regions_for_point(latitude, longitude): session = AmunSession() print(f"Getting details for point ({latitude},{longitude})") regions = session.get_region_details(latitude=latitude, longitude=longitude) numToShow = 5 print(f"found {len(regions)} regions print first {numToShow}") for val in regions[:numToShow]: print(val) print("Done")
def main(): setup_file_and_console_loggers("get_load_factors_example.log") log.info(f"Starting") # Calling with no token in constructor will load one from an environment variable if provided # or a file HOME/. session = AmunSession() turbines = session.get_turbines() windType = "era5" parameters = { "windType": windType, "turbineModelId": get_turbine_by_name(turbines, "Siemens SWT-4.0-130")["id"], "latitude": 59.59, "longitude": 0, "startTimeUTC": "2018-01-01T00:00:00.000Z", "regionCode": "GBR", "hubHeight": 90, "obstacleHeight": 0, "numberOfTurbines": 12, "roughnessLength": 0.02, "usePowerCurveSmoothing": False, # Optional # "lossesWake": 0.2, # "lossesAvailability": 0.02, # "lossesElectrical": 0.01, # "lossesTurbinePerformance": 0.1, # "lossesEnvironmental": 0.05, # "lossesOtherCurtailment": 0.0, } log.info(f"getting for {windType}") load_factors = session.run_load_factor_calculation(parameters) loadFactorRequestId = load_factors["parameters"]["loadFactorRequestId"] log.info(f"Got result for {loadFactorRequestId}") save_to_json( f"load_factors/load_factors_{datetime.now().isoformat().replace(':','_')}_{windType}_{loadFactorRequestId}.json", load_factors, )
def main(): # Calling with no token in constructor will load one from an environment variable if provided # or a file in HOME/. session = AmunSession() lat = 51.771239 lon = -1.284330 year = 2016 dataset = "NEWA" # "Era5" | "Merra2" | "NEWA" print(f"Getting wind {dataset}") windData = session.get_wind(lat=lat, lon=lon, year=year, dataset=dataset) save_to_json(f"wind/{year}_{dataset}_{lat}_{lon}.json", windData) print("Done")
def main(): setup_file_and_console_loggers("create_valuation_example.log") # Calling with no token in constructor will load one from an environment variable if provided # or a file HOME/. session = AmunSession() region = "gbr" scenarios = session.get_scenarios(region) turbines = session.get_turbines() scenario_name = "Aurora Central Weather Years - 2020 April" valuation_parameters = { "windType": "era5", "name": f"SDK Wind Farm {datetime.now()}", "description": "Created by Api", "longitude": "-1.21", "latitude": "59.59", "turbineModelId": get_turbine_by_name(turbines, "Siemens SWT-4.0-130")["id"], "numberOfTurbines": 10, "hubHeight": 90, "obstacleHeight": 0, "roughnessLength": 0.001, "scenarioId": get_scenario_by_name(scenarios, scenario_name)["id"], # Optional # "lossesWake": 0.2, # "lossesAvailability": 0.02, # "lossesElectrical": 0.01, # "lossesTurbinePerformance": 0.1, # "lossesEnvironmental": 0.05, # "lossesOtherCurtailment": 0.0, } valuation = session.create_valuation(valuation_parameters) log.info(f"Created {valuation['id']}") save_to_json(f"valuations/valuation_{valuation['id']}.json", valuation) results = session.get_valuation_results(valuation["id"], format="json", should_return_hourly_data=False) log.info(f"Got result for {results['valuation']}") save_to_json(f"valuations/valuation_{valuation['id']}_out.json", results) log.info(f"Deleting {valuation['id']}") session.delete_valuation(valuation["id"]) log.debug("Done")
def main(): setup_file_and_console_loggers("generation_valuation_example.log") # Calling with no token in constructor will load one from an environment variable if provided # or a file HOME/. session = AmunSession() region = "gbr" scenarios = session.get_scenarios(region) turbines = session.get_turbines() scenario_name = "Aurora Central Weather Years - 2020 April" valuation_parameters = { "windType": "era5", "name": f"SDK Wind Farm {datetime.now()}", "description": "Created by Api", "longitude": "-1.21", "latitude": "59.59", "scenarioId": get_scenario_by_name(scenarios, scenario_name)["id"], } valuation = session.create_valuation(valuation_parameters) log.info(f"Created {valuation['id']}") save_to_json(f"valuations/valuation_{valuation['id']}.json", valuation) # Check the json document for a complete structure of what is required # historicCalibration is for weather years session.send_calibrated_production( valuation["id"], get_json("examples\data\example_calibratedGeneration.json")) results = session.get_valuation_results(valuation["id"], format="json", should_return_hourly_data=False) log.info(f"Got result for {results['valuation']}") save_to_json(f"valuations/valuation_{valuation['id']}_out.json", results) log.info(f"Deleting {valuation['id']}") session.delete_valuation(valuation["id"]) log.debug("Done")
def main(): # Calling with no token in constructor will load one from an environment variable if provided # or a file in HOME/. session = AmunSession() print("Getting Valuations") valuations = session.get_valuations() numToShow = 5 print(f"found {len(valuations)} valuations print first {numToShow}") for val in valuations[:numToShow]: print(val) # filters valuations through the name, description and author # (includes MySQL avanced search query functionalities) filtered_valuations = session.get_valuations(searchText="test") print(f"found {len(filtered_valuations)} with the custom search text.") for val in filtered_valuations: print(val) print("Done")
def main(): log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) # Set Level for main logging in this file setup_file_and_console_loggers("authentication_example.log", log) # making a request with an invalid token throws runtime error session = AmunSession(token="Not a Real Token") log.debug("Starting") log.info("Getting Turbines with bad token") try: session.get_turbines() except RuntimeError as ex: log.error(ex) # Calling with no token in constructor will load one from an environment variable if provided # or a file in HOME/. session = AmunSession() log.info("Getting Turbines") turbines = session.get_turbines() log.info(f"found {len(turbines)} turbines") log.debug("Done")
def main(): setup_file_and_console_loggers("run_valuation_time_Based_curtailment.log") # Calling with no token in constructor will load one from an environment variable if provided # or a file HOME/. session = AmunSession() region = "gbr" scenarios = session.get_scenarios(region) turbines = session.get_turbines() # scenario_name = "Aurora Central Weather Years - 2020 April" scenario_name = "Aurora Central - 2020 October" valuation_parameters = { "windType": "era5", "name": f"SDK Wind Farm {datetime.now()}", "description": "Created by Api", "longitude": "-1.21", "latitude": "59.59", "turbineModelId": get_turbine_by_name(turbines, "Siemens SWT-4.0-130")["id"], "numberOfTurbines": 10, "hubHeight": 90, "obstacleHeight": 0, "roughnessLength": 0.001, "scenarioId": get_scenario_by_name(scenarios, scenario_name)["id"], "curtailmentThreshold": 2, # Optional "timeBasedCurtailmentThresholds": [ { "threshold": 10, "timeValidFrom": "2024-01-01T00:00:00.000Z", }, { "threshold": 20, "timeValidFrom": "2028-01-01T00:00:00.000Z", }, { "threshold": 40, "timeValidFrom": "2032-01-01T00:00:00.000Z", }, { "threshold": 60, "timeValidFrom": "2036-01-01T00:00:00.000Z", }, { "threshold": 80, "timeValidFrom": "2040-01-01T00:00:00.000Z", }, { "threshold": 100, "timeValidFrom": "2044-01-01T00:00:00.000Z", }, { "threshold": 120, "timeValidFrom": "2048-01-01T00:00:00.000Z", }, ], } valuation = session.create_valuation(valuation_parameters) log.info(f"Created {valuation['id']}") save_to_json(f"valuations/valuation_{valuation['id']}.json", valuation) results = session.get_valuation_results(valuation["id"], format="json", should_return_hourly_data=False) log.info(f"Got result for {results['valuation']}") save_to_json(f"valuations/valuation_{valuation['id']}_out.json", results) log.info(f"Deleting {valuation['id']}") session.delete_valuation(valuation["id"]) log.debug("Done")