def analyse_catchment(catchment, gauged_catchments):
    result = {}
    result['id'] = catchment.id

    analysis = QmedAnalysis(catchment)
    result['qmed_amax'] = analysis.qmed(method='amax_records')
    result['qmed_descr'] = analysis.qmed(method='descriptors')
    result['qmed_descr_1999'] = analysis.qmed(method='descriptors_1999')

    analysis.gauged_catchments = gauged_catchments
    donors = analysis.find_donor_catchments()
    analysis.idw_power = 2
    result['qmed_descr_idw'] = analysis.qmed(method='descriptors', donor_catchments=donors)

    analysis.idw_power = 3
    result['qmed_descr_idw3'] = analysis.qmed(method='descriptors', donor_catchments=donors)

    analysis.donor_weighting = 'equal'
    result['qmed_descr_first'] = analysis.qmed(method='descriptors', donor_catchments=donors[0:1])

    return result
def analyse_catchment(catchment, gauged_catchments):
    result = {}
    result['id'] = catchment.id

    analysis = QmedAnalysis(catchment)
    result['qmed_amax'] = analysis.qmed(method='amax_records')
    result['qmed_descr'] = analysis.qmed(method='descriptors')
    result['qmed_descr_1999'] = analysis.qmed(method='descriptors_1999')

    analysis.gauged_catchments = gauged_catchments
    donors = analysis.find_donor_catchments()
    analysis.idw_power = 2
    result['qmed_descr_idw'] = analysis.qmed(method='descriptors',
                                             donor_catchments=donors)

    analysis.idw_power = 3
    result['qmed_descr_idw3'] = analysis.qmed(method='descriptors',
                                              donor_catchments=donors)

    analysis.donor_weighting = 'equal'
    result['qmed_descr_first'] = analysis.qmed(method='descriptors',
                                               donor_catchments=donors[0:1])

    return result
from floodestimation.loaders import load_catchment
from floodestimation import db
from floodestimation.collections import CatchmentCollections
from floodestimation.analysis import QmedAnalysis

db_session = db.Session()

dee_catchment = load_catchment('nith_cds.cd3')
gauged_catchments = CatchmentCollections(db_session)

qmed_analysis = QmedAnalysis(dee_catchment, gauged_catchments)
print(qmed_analysis.qmed())

print(qmed_analysis.methods)

print(qmed_analysis.qmed_all_methods())

print(qmed_analysis.urban_adj_factor())

print(qmed_analysis.find_donor_catchments(5, 200.0))

qmed_analysis.idw_power = 1.5
print(qmed_analysis.idw_power)

donors = qmed_analysis.find_donor_catchments(5, 200.0)

for donor in donors:
    Q = QmedAnalysis(donors[0], gauged_catchments)
    print(donor, qmed_analysis._error_correlation(donor), Q.qmed_all_methods())
db_session.close()
from floodestimation.collections import CatchmentCollections
from floodestimation.analysis import QmedAnalysis

db_session = db.Session()

dee_catchment = load_catchment('nith_cds.cd3')
gauged_catchments = CatchmentCollections(db_session)

qmed_analysis = QmedAnalysis(dee_catchment, gauged_catchments)
print(qmed_analysis.qmed())

print(qmed_analysis.methods)

print(qmed_analysis.qmed_all_methods())

print(qmed_analysis.urban_adj_factor())

print(qmed_analysis.find_donor_catchments(5, 200.0))

qmed_analysis.idw_power = 1.5
print(qmed_analysis.idw_power)

donors = qmed_analysis.find_donor_catchments(5, 200.0)



for donor in donors:
  Q = QmedAnalysis(donors[0], gauged_catchments)
  print(donor,qmed_analysis._error_correlation(donor),Q.qmed_all_methods())
db_session.close()