Exemple #1
0
def get_project_seasonality(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    if project.windTMatrix:
        return jsonify(result={
            "exists": True,
            "seasonality": project.get_Seasonality()
        })
    else:
        return jsonify(result={"exists": False})
Exemple #2
0
def get_project_seasonality(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    if project.windTMatrix:
        return jsonify(
            result={
            "exists": True,
            "seasonality":project.get_Seasonality()
            })
    else:
        return jsonify(result={"exists": False})
Exemple #3
0
def check_wind_status(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    expected_winddays_ready = bool(project.expected_winddays)
    expected_windday_risks_ready = bool(project.expected_windday_risks)
    if expected_winddays_ready and expected_windday_risks_ready:
        project.wind_status = "Wind Day calculations ready."
        project.save()
        return jsonify(
            result={
                "status": project.wind_status,
                "byMonth": project.expected_winddays,
                "risks": project.expected_windday_risks,
                "conditions": project.windday_conditions
            })
    return jsonify(result={"status": project.wind_status})
Exemple #4
0
def check_wind_status(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    expected_winddays_ready = bool(project.expected_winddays)
    expected_windday_risks_ready = bool(project.expected_windday_risks)
    if expected_winddays_ready and expected_windday_risks_ready:
        project.wind_status = "Wind Day calculations ready."
        project.save()
        return jsonify(
            result = {
                "status": project.wind_status,
                "byMonth": project.expected_winddays,
                "risks": project.expected_windday_risks,
                "conditions": project.windday_conditions
            })
    return jsonify(
        result = {"status": project.wind_status}
        )
Exemple #5
0
def calulate_wind(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    if project.windTMatrix:
        try:
            conditions = request.json
            project.windday_conditions = conditions
            project.expected_winddays = []
            project.expected_windday_risks = []
            project.wind_status = "Calculating Expected Risks of Wind Days"
            project.save()
            expected = calculate_expected_winddays.delay(*(g.username, project_name))
            risks = calculate_windday_risks.delay(*(g.username, project_name))
        except Exception as e:
            project.wind_status = "Error Calculating Wind Days"
            raise ProjectException("Error Calculating Wind Days: " + str(e))
        return jsonify(result={"message": project.wind_status})
    else:
        raise ProjectException("Please upload wind data.")
Exemple #6
0
def calulate_wind(project_name):
    user, project = Project.get_user_and_project(g.username, project_name)
    if project.windTMatrix:
        try:
            conditions = request.json
            project.windday_conditions = conditions
            project.expected_winddays = []
            project.expected_windday_risks = []
            project.wind_status = "Calculating Expected Risks of Wind Days"
            project.save()
            expected = calculate_expected_winddays.delay(*(g.username,
                                                           project_name))
            risks = calculate_windday_risks.delay(*(g.username, project_name))
        except Exception as e:
            project.wind_status = "Error Calculating Wind Days"
            raise ProjectException("Error Calculating Wind Days: " + str(e))
        return jsonify(result={"message": project.wind_status})
    else:
        raise ProjectException("Please upload wind data.")
Exemple #7
0
def calculate_windday_risks(username, project_name):
    user, project = Project.get_user_and_project(username, project_name)
    try:
        project.expected_windday_risks = []
        project.save()
        risks = risk_by_hour_and_month(
            project.windHeight,
            project.windday_conditions['height'],
            project.windday_conditions['maxws'],
            project.windday_conditions['maxhours'],
            project.windday_conditions['daylength'],
            project.get_TMatrix(),
            consecutive=project.windday_conditions['consecutive'])
        project.expected_windday_risks = risks
        project.save()
        return risks
    except Exception as e:
        project.wind_status = "Error Calculating Wind Days"
        project.save()
        print "Error Calculating Wind Days Risks: " + str(e)
Exemple #8
0
def calculate_windday_risks(username, project_name):
    user, project = Project.get_user_and_project(username, project_name)
    try:
        project.expected_windday_risks = []
        project.save()
        risks = risk_by_hour_and_month(
            project.windHeight,
            project.windday_conditions['height'],
            project.windday_conditions['maxws'],
            project.windday_conditions['maxhours'],
            project.windday_conditions['daylength'],
            project.get_TMatrix(),
            consecutive=project.windday_conditions['consecutive']
            )
        project.expected_windday_risks = risks
        project.save()
        return risks
    except Exception as e:
        project.wind_status = "Error Calculating Wind Days"
        project.save()
        print "Error Calculating Wind Days Risks: " + str(e)
Exemple #9
0
def calculate_expected_winddays(username, project_name):
    user, project = Project.get_user_and_project(username, project_name)
    try:
        project.expected_winddays = []
        project.save()
        winddays = estimate_winddays(
            project.windHeight,
            project.windday_conditions['height'],
            project.windday_conditions['maxws'],
            project.windday_conditions['maxhours'],
            project.windday_conditions['starthr'],
            project.windday_conditions['daylength'],
            project.get_TMatrix(),
            project.windday_conditions['certainty'],
            consecutive=project.windday_conditions['consecutive'])
        project.expected_winddays = winddays
        project.save()
        return winddays
    except Exception as e:
        project.wind_status = "Error Calculating Wind Days"
        project.save()
        print "Error Calculating Wind Days: " + str(e)
Exemple #10
0
def calculate_expected_winddays(username, project_name):
    user, project = Project.get_user_and_project(username, project_name)
    try:
        project.expected_winddays = []
        project.save()
        winddays = estimate_winddays(
                       project.windHeight,
                       project.windday_conditions['height'],
                       project.windday_conditions['maxws'],
                       project.windday_conditions['maxhours'],
                       project.windday_conditions['starthr'],
                       project.windday_conditions['daylength'],
                       project.get_TMatrix(),
                       project.windday_conditions['certainty'],
                       consecutive = project.windday_conditions['consecutive']
                       )
        project.expected_winddays = winddays
        project.save()
        return winddays
    except Exception as e:
        project.wind_status = "Error Calculating Wind Days"
        project.save()
        print "Error Calculating Wind Days: " + str(e)