Exemple #1
0
def test_AlloUsage1():
    a1 = AlloUsage(from_date, to_date, site_filter=site_filter)
    combo_ts1 = a1.get_ts(datasets, 'A-JUN', cols)
    combo_ts2 = a1.get_ts(datasets, 'M', cols)
    a1.plot_group(freq, export_path=base_dir)
    a1.plot_stacked(freq, export_path=base_dir)

    assert (len(combo_ts1) == 73) & (len(combo_ts2) == 869)
### Test 4
sites1 = mssql.rd_sql(server,
                      database,
                      sites_table,
                      ['ExtSiteID', 'CatchmentGroupName', summ_col],
                      where_in={'CatchmentGroupName': catch_group})

site_filter = {'SwazName': sites1.SwazName.unique().tolist()}

a1 = AlloUsage(from_date, to_date, site_filter=site_filter)

ts1 = a1.get_ts(datasets, freq, cols, irr_season=True)

a1.plot_group(
    'A-JUN',
    val='total',
    with_restr=True,
    export_path=r'E:\ecan\local\Projects\requests\suz\2018-12-17\plots')

a1.plot_stacked(
    'A-JUN',
    val='total',
    export_path=r'E:\ecan\local\Projects\requests\suz\2018-12-17\plots')

### Test 5
a1 = AlloUsage(from_date, to_date, site_filter=waitaki)

a1.allo.to_csv(os.path.join(export_path, 'waitaki_allo_2019-02-27.csv'))

a1.allo_wap.to_csv(os.path.join(export_path,
                                'waitaki_allo_wap_2019-02-27.csv'))
Exemple #3
0
               site_filter=site_filter,
               crc_filter=crc_filter)

combo_ts = a1.get_ts(datasets,
                     freq, ['SwazName', 'use_type', 'date'],
                     irr_season=True)

combo_ts.to_csv(os.path.join(export_dir, export2))

#########################################
### Plotting

### Grouped
## Lumped
a1.plot_group('A-JUN',
              group='SwazGroupName',
              export_path=os.path.join(export_dir, plot_dir),
              irr_season=True)

## broken up
a1.plot_group('A-JUN',
              group='SwazName',
              export_path=os.path.join(export_dir, plot_dir),
              irr_season=True)

### Stacked
## lumped
a1.plot_stacked('A-JUN',
                group='SwazGroupName',
                export_path=os.path.join(export_dir, plot_dir),
                irr_season=True)
               site_filter=site_filter,
               crc_filter=crc_filter)

combo_ts = a1.get_ts(datasets,
                     freq, ['SwazName', 'use_type', 'date'],
                     irr_season=True)

combo_ts.to_csv(os.path.join(py_path, export2))

#########################################
### Plotting

### Grouped
## Lumped
a1.plot_group('A-JUN',
              group='SwazGroupName',
              export_path=plot_path,
              irr_season=True)

## broken up
a1.plot_group('A-JUN',
              group='SwazName',
              export_path=plot_path,
              irr_season=True)

### Stacked
## lumped
a1.plot_stacked('A-JUN',
                group='SwazGroupName',
                export_path=plot_path,
                irr_season=True)
########################################
### Read in sites

test_crc = pd.read_csv(test_sites_csv).crc.unique().tolist()

########################################
### generate!

#sites1 = mssql.rd_sql(server, database, sites_table, ['ExtSiteID', 'CatchmentGroupName', summ_col], where_in={'CatchmentGroupName': catch_group})
#
#site_filter = {'SwazName': sites1.SwazName.unique().tolist()}

a1 = AlloUsage()

a1 = AlloUsage(from_date, to_date, crc_filter={'crc': test_crc})

ts1 = a1.get_ts(datasets, freq, cols, usage_allo_ratio=2)

ts1.to_csv(os.path.join(export_path, export1))

a1.plot_group('A-JUN',
              val='total',
              group='crc',
              with_restr=False,
              export_path=export_path)

# a1.plot_stacked('A-JUN', val='total', export_path=r'E:\ecan\local\Projects\requests\suz\2018-12-17\plots')

self = AlloUsage()