Esempio n. 1
0
            
            lowflow_index = Platypus.calcLowFlowIndex(year_data, flow_col, summerlow, winterlow, summerlowday, winterlowday, index_method="linear_scaling") # method = "min_duration" or "linear_scaling"
            food_index, dispersal_index = Platypus.calcFoodDispIndex(year_data, flow_col, freshes, durations, frequencies, timing)
            burrow_index = Platypus.calcBurrowIndex(year_data, flow_col, burrow_startmonth, burrow_endmonth, entrance_buffer, breeding_startmonth, breeding_endmonth)
            
            #platypus_index = pd.DataFrame(index=["{y}/{s0}/{s1}-{y1}/{e0}/{e1}".format(y=year, y1=year+1, s0=start_time[0], s1=start_time[1], e0=end_time[0], e1=end_time[1])])
            platypus_index = pd.DataFrame(index=["{y}/{s0}-{y1}/{e0}".format(y=year, y1=year+1, s0=start_time[0], e0=end_time[0])])
            platypus_index['lowflow_index'] = lowflow_index
            platypus_index['food_index'] = food_index
            platypus_index['dispersal_index'] = dispersal_index
            platypus_index['burrow_index'] = burrow_index
#            platypus_index['annualflow']=annualflow

            #Add to benchmark dataframe
            platypusIndexes = platypusIndexes.append(platypus_index)

        #End if

    #End for
    platypusIndexes['platypus_index']=platypusIndexes.mean(axis=1)
    platypusIndexes['platypus_rolling_index']=pd.rolling_mean(platypusIndexes['platypus_index'],3)

    print platypusIndexes.describe()
    platypusIndexes["platypus_rolling_index"].plot(marker='o')
#    platypusIndexes.index.name = 'Time'
#    ggplot(platypusIndexes,aes(x='Time', y='platypus_rolling_index'))+geom_line()

FileHandle.writeCSV(platypusIndexes, "./Integrated/Modules/Ecology/Outputs", "platypus_index.csv")

FileHandle.writeCSV(flow_data, "./Integrated/Modules/Ecology/Outputs", "platypus_flowdata.csv")
Esempio n. 2
0
            platypus_index = pd.DataFrame(index=[
                "{y}/{s0}-{y1}/{e0}".format(
                    y=year, y1=year + 1, s0=start_time[0], e0=end_time[0])
            ])
            platypus_index['lowflow_index'] = lowflow_index
            platypus_index['food_index'] = food_index
            platypus_index['dispersal_index'] = dispersal_index
            platypus_index['burrow_index'] = burrow_index
            #            platypus_index['annualflow']=annualflow

            #Add to benchmark dataframe
            platypusIndexes = platypusIndexes.append(platypus_index)

        #End if

    #End for
    platypusIndexes['platypus_index'] = platypusIndexes.mean(axis=1)
    platypusIndexes['platypus_rolling_index'] = pd.rolling_mean(
        platypusIndexes['platypus_index'], 3)

    print platypusIndexes.describe()
    platypusIndexes["platypus_rolling_index"].plot(marker='o')
#    platypusIndexes.index.name = 'Time'
#    ggplot(platypusIndexes,aes(x='Time', y='platypus_rolling_index'))+geom_line()

FileHandle.writeCSV(platypusIndexes, "./Integrated/Modules/Ecology/Outputs",
                    "platypus_index.csv")

FileHandle.writeCSV(flow_data, "./Integrated/Modules/Ecology/Outputs",
                    "platypus_flowdata.csv")
Esempio n. 3
0
            #For development purposes only. Display index results for each species

            for species in specieslist:

                save_folder = "./Integrated/Modules/Ecology/Outputs/{s}/{asset}/{sp}".format(s=scen_name, asset=eco_site, sp=species)

                species_index = flow_indexes[species]
                all_index = species_index['gw'][['gw_suitability_index','sw_suitability_index','water_suitability_index']]
                all_index_annual = all_index.resample("A", how='sum')
                all_index_rolling = pd.rolling_mean(all_index_annual,3)
                
                print scen_name,eco_site, species
                all_index_annual.plot()
                
                FileHandle.writeCSV(all_index, save_folder, "all_index_daily.csv")
                FileHandle.writeCSV(all_index_annual, save_folder, "all_index_annual.csv")
                FileHandle.writeCSV(all_index_rolling, save_folder, "all_index_rolling.csv")
                

#                print species
#                print "---- Groundwater ----"
#                FileHandle.writeCSV(species_index['gw'], save_folder, "gw.csv")
#                # print species_index['gw']
#                print "---------------------"
#                print "---- Surface Water ----"
#                FileHandle.writeCSV(species_index['sw'], save_folder, "sw.csv")
#                # print species_index['sw']
#                print "---------------------"
#                print "---- Water Index ----"
#                FileHandle.writeCSV(species_index['water_index'], save_folder, "water_index.csv")
Esempio n. 4
0
                #End if
                Manager.season_started = False

                #Debugging counter
                season_counter = 0

                year_counter += 1

                #Reset pumping costs for next timestep
                for f in Manager.Farm.fields:
                    pumping_costs[f.name] = 0
            #End if
        #End if

        assert pd.to_datetime(str(timestep)) == current_ts, "Somehow the timestep changed! {} - {}".format(timestep, current_ts)

        timestep = loop_timestep

    #End while

    #print long_results
    # OUTPUT RESULTS ABOVE INTO CSV FOR VISUALIZATION
    for Field in Manager.Farm.fields:
        long_results[Field.name].loc['Total', :] = long_results[Field.name].sum(axis=0, numeric_only=True, skipna=False)
        FileHandler.writeCSV(long_results[Field.name], 'output', '2nd_phase_{f}.csv'.format(f=Field.name))
        FileHandler.writeCSV(irrigation_log[Field.name], 'output', '2nd_phase_{f}_irrig_log.csv'.format(f=Field.name))
    #End for

    print "==== DONE ===="

Esempio n. 5
0
            ])
            fish_index['lowflow_index'] = lowflow_index
            fish_index['spawning_index'] = spawn_index
            fish_index['dispersal_index'] = dispersal_index
            fish_index['washout_index'] = washout_index

            #            fish_index['annualflow']=annualflow

            #Add to benchmark dataframe
            fishIndexes = fishIndexes.append(fish_index)

        #End if

    #End for
    fishIndexes['long_lived_fish_index'] = fishIndexes.mean(axis=1)
    fishIndexes['short_lived_fish_index'] = fishIndexes['lowflow_index']

    fishIndexes['short_lived_fish_rindex'] = pd.rolling_mean(
        fishIndexes['short_lived_fish_index'], 2)
    fishIndexes['long_lived_fish_rindex'] = pd.rolling_mean(
        fishIndexes['long_lived_fish_index'], 4)

    print fishIndexes.describe()
    fishIndexes["short_lived_fish_rindex"].plot()
    fishIndexes["long_lived_fish_rindex"].plot(color="red")

FileHandle.writeCSV(fishIndexes, "./Integrated/Modules/Ecology/Outputs",
                    "fish_index.csv")

#FileHandle.writeCSV(flow_data, "./Integrated/Modules/Ecology/Outputs", "fish_flowdata.csv")
Esempio n. 6
0
                Manager.season_started = False

                # Debugging counter
                season_counter = 0

                year_counter += 1

                # Reset pumping costs for next timestep
                for f in Manager.Farm.fields:
                    pumping_costs[f.name] = 0
            # End if
        # End if

        assert pd.to_datetime(str(timestep)) == current_ts, "Somehow the timestep changed! {} - {}".format(
            timestep, current_ts
        )

        timestep = loop_timestep

    # End while

    # print long_results
    # OUTPUT RESULTS ABOVE INTO CSV FOR VISUALIZATION
    for Field in Manager.Farm.fields:
        long_results[Field.name].loc["Total", :] = long_results[Field.name].sum(axis=0, numeric_only=True, skipna=False)
        FileHandler.writeCSV(long_results[Field.name], "output", "2nd_phase_{f}.csv".format(f=Field.name))
        FileHandler.writeCSV(irrigation_log[Field.name], "output", "2nd_phase_{f}_irrig_log.csv".format(f=Field.name))
    # End for

    print "==== DONE ===="
Esempio n. 7
0
                save_folder = "./Integrated/Modules/Ecology/Outputs/{s}/{asset}/{sp}".format(
                    s=scen_name, asset=eco_site, sp=species)

                species_index = flow_indexes[species]
                all_index = species_index['gw'][[
                    'gw_suitability_index', 'sw_suitability_index',
                    'water_suitability_index'
                ]]
                all_index_annual = all_index.resample("A", how='sum')
                all_index_rolling = pd.rolling_mean(all_index_annual, 3)

                print scen_name, eco_site, species
                all_index_annual.plot()

                FileHandle.writeCSV(all_index, save_folder,
                                    "all_index_daily.csv")
                FileHandle.writeCSV(all_index_annual, save_folder,
                                    "all_index_annual.csv")
                FileHandle.writeCSV(all_index_rolling, save_folder,
                                    "all_index_rolling.csv")

#                print species
#                print "---- Groundwater ----"
#                FileHandle.writeCSV(species_index['gw'], save_folder, "gw.csv")
#                # print species_index['gw']
#                print "---------------------"
#                print "---- Surface Water ----"
#                FileHandle.writeCSV(species_index['sw'], save_folder, "sw.csv")
#                # print species_index['sw']
#                print "---------------------"
#                print "---- Water Index ----"
Esempio n. 8
0
            
            #fish_index = pd.DataFrame(index=["{y}/{s0}/{s1}-{y1}/{e0}/{e1}".format(y=year, y1=year+1, s0=start_time[0], s1=start_time[1], e0=end_time[0], e1=end_time[1])])
            fish_index = pd.DataFrame(index=["{y}/{s0}-{y1}/{e0}".format(y=year, y1=year+1, s0=start_time[0], e0=end_time[0])])
            fish_index['lowflow_index'] = lowflow_index
            fish_index['spawning_index'] = spawn_index            
            fish_index['dispersal_index'] = dispersal_index
            fish_index['washout_index'] = washout_index

#            fish_index['annualflow']=annualflow

            #Add to benchmark dataframe
            fishIndexes = fishIndexes.append(fish_index)

        #End if

    #End for
    fishIndexes['long_lived_fish_index']=fishIndexes.mean(axis=1)
    fishIndexes['short_lived_fish_index']=fishIndexes['lowflow_index']
    
    fishIndexes['short_lived_fish_rindex']=pd.rolling_mean(fishIndexes['short_lived_fish_index'],2)
    fishIndexes['long_lived_fish_rindex']=pd.rolling_mean(fishIndexes['long_lived_fish_index'],4)

    print fishIndexes.describe()
    fishIndexes["short_lived_fish_rindex"].plot()
    fishIndexes["long_lived_fish_rindex"].plot(color="red")   

FileHandle.writeCSV(fishIndexes, "./Integrated/Modules/Ecology/Outputs", "fish_index.csv")

#FileHandle.writeCSV(flow_data, "./Integrated/Modules/Ecology/Outputs", "fish_flowdata.csv")