In [1]:
    
# Reload when code changed:
%load_ext autoreload
%autoreload 2
%pwd
    
    Out[1]:
In [2]:
    
import os 
import core
import importlib
importlib.reload(core) 
import pandas as pd
pd.__version__
    
    Out[2]:
In [3]:
    
root_directory = os.getcwd()
workspace_directory = root_directory + '/workspaces' 
resource_directory = root_directory + '/resources'
    
In [4]:
    
default_workspace = core.WorkSpace(name='default', 
                                   parent_directory=workspace_directory, 
                                   resource_directory=resource_directory)
    
    
In [5]:
    
lv_workspace = core.WorkSpace(name='lv', 
                              parent_directory=workspace_directory, 
                              resource_directory=resource_directory)
    
    
In [6]:
    
lv_workspace.add_files_from_workspace(default_workspace, overwrite=True)
    
    
In [7]:
    
lv_workspace.load_all_data()
    
    
    
    
    
In [8]:
    
# show available waterbodies
workspace_data = lv_workspace.data_handler.get_all_column_data_df()
lst = workspace_data.WATER_TYPE_AREA.unique()
print('Type Areas in dataset:\n{}'.format('\n'.join(lst)))
    
    
In [9]:
    
lst = workspace_data.SEA_AREA_NAME.unique()
print('Waterbodies in dataset:\n{}'.format('\n'.join(lst)))
    
    
In [10]:
    
include_WB = ['Gullmarn centralbassäng', 'Rivö fjord', 'Byfjorden', 'Havstensfjorden']
include_stations = [] 
exclude_stations = []
include_years = ['2015', '2017'] 
lv_workspace.set_data_filter(step=0, filter_type='include_list', filter_name='SEA_AREA_NAME', data=include_WB)
lv_workspace.set_data_filter(step=0, filter_type='include_list', filter_name='STATN', data=include_stations) 
lv_workspace.set_data_filter(step=0, filter_type='exclude_list', filter_name='STATN', data=exclude_stations) 
lv_workspace.set_data_filter(step=0, filter_type='include_list', filter_name='MYEAR', data=include_years)
    
    
In [11]:
    
lv_workspace.apply_first_filter() # This sets the first level of data filter in the IndexHandler
    
    Out[11]:
In [12]:
    
data_after_first_filter = lv_workspace.get_filtered_data(level=0) # level=0 means first filter 
print('{} rows mathing the filter criteria'.format(len(data_after_first_filter)))
data_after_first_filter.head()
    
    
    Out[12]:
In [13]:
    
include_WB = ['Gullmarn centralbassäng', 'Rivö fjord']
include_stations = ['BJÖRKHOLMEN'] 
# Lägg till något som kan plocka in stationer öven ifrån närliggande WB?
exclude_stations = ['SLÄGGÖ'] # Example that both include and exclude are possible 
include_years = ['2016', '2017']  
lv_workspace.set_data_filter(step=1, subset='A', filter_type='include_list', filter_name='SEA_AREA_NAME', data=include_WB)
lv_workspace.set_data_filter(step=1, subset='A', filter_type='include_list', filter_name='STATN', data=include_stations)
lv_workspace.set_data_filter(step=1, subset='A', filter_type='exclude_list', filter_name='STATN', data=exclude_stations)
lv_workspace.set_data_filter(step=1, subset='A', filter_type='include_list', filter_name='MYEAR', data=include_years)
    
    
In [ ]:
    
    
In [15]:
    
lv_workspace.apply_subset_filter(subset='A') # Not handled properly by the IndexHandler
    
    Out[15]:
In [16]:
    
data_after_subset_filter = lv_workspace.get_filtered_data(level=1, subset='A') # level=0 means first filter 
print('{} rows mathing the filter criteria'.format(len(data_after_subset_filter)))
data_after_subset_filter.head()
    
    
    Out[16]:
In [ ]:
    
    
In [17]:
    
import numpy as np
np.where(lv_workspace.index_handler.subset_filter)
    
    Out[17]:
In [18]:
    
f = lv_workspace.get_data_filter_object(step=1, subset='A')
    
In [19]:
    
f.all_filters
    
    Out[19]:
In [20]:
    
f.exclude_list_filter
    
    Out[20]:
In [21]:
    
f.include_list_filter
    
    Out[21]:
In [22]:
    
s = lv_workspace.get_step_1_object('A')
    
In [23]:
    
s.data_filter.all_filters
    
    Out[23]:
In [24]:
    
f0 = lv_workspace.get_data_filter_object(step=0)
    
In [25]:
    
f0.exclude_list_filter
    
    Out[25]:
In [26]:
    
f0.include_list_filter
    
    Out[26]:
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]: