Ejemplo n.º 1
0
import os
import numpy as np

if __name__ == '__main__':
    #import os
    #os.chdir('C:\\UserData\\fub\\work09\\MDB')

    from integrated.Modules.Core.Handlers.FileHandler import FileHandler
    from integrated.Modules.Ecology.PlatypusFlow import PlatypusFlow
#    from integrated.Modules.Ecology.SpeciesFlow import SpeciesFlow
    import pandas as pd
    import datetime
    from datetime import timedelta
    
    #import flow dev data
    FileHandle = FileHandler()
    #Paths to files
    #dev_data_path = "integrated/Modules/Ecology/Inputs"
    dev_data_path = "Inputs"

    # Read in flow data
    
    #flow_data_path = "integrated/Modules/Ecology/Inputs/Hydrology/sce1/406201.csv" #201,202, 265
    flow_data_path = dev_data_path+"/Hydrology/sce1/406201.csv"

    flow_data = FileHandle.loadCSV(flow_data_path, index_col="Date", parse_dates=True, dayfirst=True)
    flow_data[flow_data<0] = np.nan
    
    flow_col = "Flow"

    #import environmental flow requirement data
Ejemplo n.º 2
0
from integrated.Modules.Core.Handlers.FileHandler import FileHandler
from integrated.Modules.Hydrology.IHACRES.IHACRES import IHACRES
import pandas as pd

if __name__ == '__main__':

    ClimateData = FileHandler().loadCSV('test_data/climate/Echuca.txt',
                                        columns=[0, 7, 9],
                                        skiprows=41,
                                        delimiter=r'\s*',
                                        engine='python')  #
    ClimateData.index = pd.to_datetime(ClimateData[ClimateData.columns[0]],
                                       format='%Y%m%d')
    ClimateData.columns = ['Date', 'rainfall', 'ET']

    RRmodel = IHACRES(ClimateData, 50)

    prev_storage = 50
    inflow = 100
    irrig_out = 25
    evap = 10
    local_inflow = 10
    base_flow = 5
    deep_drainage = 10
    storage_coef = 0.5
    ET_f = 1.1

    #Test flow calculation
    print RRmodel.calcFlow(prev_storage, inflow, irrig_out, evap, local_inflow,
                           base_flow, deep_drainage, storage_coef, ET_f)
Ejemplo n.º 3
0
     max_separation=getAssetParam(asset_table, gauge, 'Event_gap'), \
     min_duration=getAssetParam(asset_table, gauge, 'Event_dur') )


#End envIndex()

# ## Function to calculate median/total flow/baseflow levels (annual), if total, fun=sum.
# flowsum <- function (x,fun=median,...){
#   summaryby <- as.POSIXlt(time(x))$year + 1900
#   flowsummary <- aggregate(x, by=summaryby, FUN = fun, na.rm=TRUE)
#   return(round(flowsummary,2))
# }

### Script starts here ###

FileHandle = FileHandler()

#Read in input data

## Read in input data

# read in all breakpoint files from 1900 til end of file
date_range = ["1900-01-01", None]
indexes = FileHandle.importFiles("Inputs/index", ext=".csv", walk=False)

# read in asset table
#This could be set as class attribute as it is used as a global in the R script
asset_table = FileHandle.loadCSV("Inputs/ctf_dss.csv")

# read in weights
weightall = FileHandle.loadCSV("Inputs/index/weight/weight.csv")
Ejemplo n.º 4
0
#main_hydro_dev.py

if __name__ == '__main__':

    import numpy as np
    import pandas as pd

    from integrated.Modules.Core.Handlers.FileHandler import FileHandler
    from Hydrology import Hydrology

    import datetime

    #Set up the file handler
    FileHandle = FileHandler()

    #Import all the files from the data directory
    data_path = "data"
    data = FileHandle.importFiles(data_path, ext=".csv", walk=False, dayfirst=True)
    data = data["data"] #Remove parent directory from listing

    #Set node_ids as index where possible
    for name, df in data.iteritems():
        try:
            df.index = df['node']
        except KeyError as e:
            #Doesn't have node column
            #Safe to skip
            continue
        #End try
    #End for
Ejemplo n.º 5
0
from integrated.Modules.Core.Handlers.FileHandler import FileHandler
from integrated.Modules.Hydrology.Routing.Routing import Routing
import pandas as pd

if __name__ == "__main__":

    ClimateData = FileHandler().loadCSV(
        "test_data/climate/Echuca.txt", columns=[0, 7, 9], skiprows=41, delimiter=r"\s*", engine="python"
    )  #
    ClimateData.index = pd.to_datetime(ClimateData[ClimateData.columns[0]], format="%Y%m%d")
    ClimateData.columns = ["Date", "rainfall", "ET"]

    WaterRouter = Routing(ClimateData, 50)

    prev_storage = 50
    inflow = 100
    irrig_out = 25
    evap = 10
    local_inflow = 10
    base_flow = 5
    deep_drainage = 10
    storage_coef = 0.5
    ET_f = 1.1

    # Test flow calculation
    print WaterRouter.calcFlow(
        prev_storage, inflow, irrig_out, evap, local_inflow, base_flow, deep_drainage, storage_coef, ET_f
    )
Ejemplo n.º 6
0
import os
import numpy as np

if __name__ == '__main__':
    #import os
    #os.chdir('C:\\UserData\\fub\\work09\\MDB')

    from integrated.Modules.Core.Handlers.FileHandler import FileHandler
    from integrated.Modules.Ecology.PlatypusFlow import PlatypusFlow
    #    from integrated.Modules.Ecology.SpeciesFlow import SpeciesFlow
    import pandas as pd
    import datetime
    from datetime import timedelta

    #import flow dev data
    FileHandle = FileHandler()
    #Paths to files
    #dev_data_path = "integrated/Modules/Ecology/Inputs"
    dev_data_path = "Inputs"

    # Read in flow data

    #flow_data_path = "integrated/Modules/Ecology/Inputs/Hydrology/sce1/406201.csv" #201,202, 265
    flow_data_path = dev_data_path + "/Hydrology/sce1/406201.csv"

    flow_data = FileHandle.loadCSV(flow_data_path,
                                   index_col="Date",
                                   parse_dates=True,
                                   dayfirst=True)
    flow_data[flow_data < 0] = np.nan
Ejemplo n.º 7
0
#flow_dev.py


if __name__ == '__main__':

    #import os
    #os.chdir('C:\\UserData\\fub\\work09\\MDB')
    from integrated.Modules.Ecology.FlowSuitability import FlowSuitability
    from integrated.Modules.Core.Handlers.FileHandler import FileHandler
    import pandas as pd

    FileHandle = FileHandler()

    #Paths to files
    dev_data_path = "Integrated/Modules/Ecology/Inputs"
    #dev_data_path = "Inputs"

    # Read in flow data
    scenarios = [dev_data_path+"/Hydrology/sce1"]#, dev_data_path+"/Hydrology/sce2"]

    date_range = ["1900-01-01", None]

    # Read in index data
    # NOTE: Left most column will be used as the DataFrame index
    indexes = FileHandle.importFiles(dev_data_path+"/Ecology/index", ext=".csv", index_col=0, walk=False)
    indexes = indexes["index"] #Remove parent folder listing from Dict, as this is unneeded

    # read in asset table
    #This could be set as class attribute as it is used as a global in the R script
    asset_table = FileHandle.loadCSV(dev_data_path+"/Ecology/Water_suitability_param.csv")
    eco_assets = ['A2','A4','A5']
Ejemplo n.º 8
0
    name='ASR',
    num_years=20,
    storage_capacity_ML=200,
    storage_cost_per_ML=0,
    capital_cost_per_ML_at_02_per_day=700, #TESTING, REMOVE WHEN DONE
    cost_capital=0,
    maintenance_rate=0.07,
    capture_pump_cost_ratio=0.6,
    pump_cost_dollar_per_ML=35,
    ClimateVariables=ParameterSet(surface_evap_rate=0.4),
    # WaterSources=WaterSources(water_source={'flood_harvest': 200})
)

### Import data from files ###

DataHandle = FileHandler()

#Water Costs
#Groundwater
gw_costs = DataHandle.importFiles('WaterSources/data/costs/groundwater', index_col=0, skipinitialspace=True, walk=True)
sw_costs = DataHandle.importFiles('WaterSources/data/costs/surface_water', index_col=0, skipinitialspace=True, walk=True)

#Irrigations
irrigation_data = {}
irrigation_files = DataHandle.importFiles('Irrigations/data', index_col=0, skipinitialspace=True)
irrigation_params = {}

for folder in irrigation_files:

    for irrigation_name in irrigation_files[folder]:
Ejemplo n.º 9
0
from integrated.Modules.Core.Handlers.FileHandler import FileHandler
from integrated.Modules.Hydrology.IHACRES.IHACRES import IHACRES
import pandas as pd

if __name__ == '__main__':

    ClimateData = FileHandler().loadCSV('test_data/climate/Echuca.txt', columns=[0, 7, 9], skiprows=41, delimiter=r'\s*', engine='python') #
    ClimateData.index = pd.to_datetime(ClimateData[ClimateData.columns[0]], format='%Y%m%d')
    ClimateData.columns = ['Date', 'rainfall', 'ET']

    RRmodel = IHACRES(ClimateData, 50)

    prev_storage = 50
    inflow = 100
    irrig_out = 25
    evap = 10
    local_inflow = 10
    base_flow = 5
    deep_drainage = 10
    storage_coef = 0.5
    ET_f = 1.1

    #Test flow calculation
    print RRmodel.calcFlow(prev_storage, inflow, irrig_out, evap, local_inflow, base_flow, deep_drainage, storage_coef, ET_f)
Ejemplo n.º 10
0
    #Tired of having columns split over several lines
    pd.set_option('max_colwidth', 5000)
    pd.set_option('display.width', 5000)

    TestFarm = FarmInfo(**FarmConfig.BASE_FARM.getParams())
    test_farm_area = 100 #100 Ha

    print "Processing {farm_name}".format(farm_name=TestFarm.name)
    print "--------------------------"

    print "Setting up historical data for Echuca area"
    print "--------------------------"

    #Real data for Echuca
    ClimateData = FileHandler().loadCSV('test_data/climate/climate.csv', columns=['Date', '406265_rain', '406265_evap'], index_col=0, dayfirst=True, parse_dates=True)
    ClimateData.index.name = 'Date'
    ClimateData.columns = ['rainfall', 'ET']

    Climate = Climate(data=ClimateData, low_rainfall_thres_mm=400, high_rainfall_thres_mm=500)
    SurfacePolicy = SurfaceWaterPolicy(Climate)

    #Determine water source costs
    #TODO: Separate this out!
    sw_yearly = FarmConfig.sw_costs['Campaspe']['yearly_costs']
    sw_seasonal = FarmConfig.sw_costs['Campaspe']['water_costs']

    sw_yearly_costs = sw_yearly.loc[['service', 'service_point', 'service_point_local_read', 'surface_drainage_service'], :].sum()['Amount ($/Point)']

    #12ML/Day irrigation system capacity, price simulator says to divide entitlement with 100 = 4.35
    sw_yearly_costs += sw_yearly.loc[['infrastructure_access (ML/Day)'], :].sum()['Amount ($/Point)'] * 0 #4.35 
Ejemplo n.º 11
0
    pd.set_option("display.width", 5000)

    TestFarm = FarmInfo(**FarmConfig.BASE_FARM.getParams())
    test_farm_area = 100  # 100 Ha

    print "Processing {farm_name}".format(farm_name=TestFarm.name)
    print "--------------------------"

    print "Setting up historical data for Echuca area"
    print "--------------------------"

    # Real data for Echuca
    ClimateData = FileHandler().loadCSV(
        "test_data/climate/climate.csv",
        columns=["Date", "406265_rain", "406265_evap"],
        index_col=0,
        dayfirst=True,
        parse_dates=True,
    )
    ClimateData.index.name = "Date"
    ClimateData.columns = ["rainfall", "ET"]

    Climate = Climate(data=ClimateData, low_rainfall_thres_mm=400, high_rainfall_thres_mm=500)
    SurfacePolicy = SurfaceWaterPolicy(Climate)

    # Determine water source costs
    # TODO: Separate this out!
    sw_yearly = FarmConfig.sw_costs["Campaspe"]["yearly_costs"]
    sw_seasonal = FarmConfig.sw_costs["Campaspe"]["water_costs"]

    sw_yearly_costs = sw_yearly.loc[
Ejemplo n.º 12
0
#flow_dev.py

if __name__ == '__main__':

    #import os
    #os.chdir('C:\\UserData\\fub\\work09\\MDB')
    from integrated.Modules.Ecology.FlowSuitability import FlowSuitability
    from integrated.Modules.Core.Handlers.FileHandler import FileHandler
    import pandas as pd

    FileHandle = FileHandler()

    #Paths to files
    dev_data_path = "Integrated/Modules/Ecology/Inputs"
    #dev_data_path = "Inputs"

    # Read in flow data
    scenarios = [dev_data_path + "/Hydrology/sce1"
                 ]  #, dev_data_path+"/Hydrology/sce2"]

    date_range = ["1900-01-01", None]

    # Read in index data
    # NOTE: Left most column will be used as the DataFrame index
    indexes = FileHandle.importFiles(dev_data_path + "/Ecology/index",
                                     ext=".csv",
                                     index_col=0,
                                     walk=False)
    indexes = indexes[
        "index"]  #Remove parent folder listing from Dict, as this is unneeded