In [1]:
# coding: utf-8

# In[1]:


import os 
import sys
path = "../"
path = "D:/github/w_vattenstatus/ekostat_calculator"
sys.path.append(path)
#os.path.abspath("../")
print(os.path.abspath(path))


# In[2]:


import pandas as pd
import numpy as np
import json
import timeit
import time
import core
import importlib
importlib.reload(core)
import logging
importlib.reload(core) 
try:
    logging.shutdown()
    importlib.reload(logging)
except:
    pass
from event_handler import EventHandler
print(core.__file__)
pd.__version__


D:\github\w_vattenstatus\ekostat_calculator
D:/github/w_vattenstatus/ekostat_calculator\core\__init__.py
Out[1]:
'0.19.2'
#

Load directories


In [2]:
root_directory = 'D:/github/w_vattenstatus/ekostat_calculator'#"../" #os.getcwd()
workspace_directory = root_directory + '/workspaces' 
resource_directory = root_directory + '/resources'
#alias = 'lena'
user_id = 'test_user' #kanske ska vara off_line user?
workspace_alias = 'lena_indicator' 

# ## Initiate EventHandler
print(root_directory)
paths = {'user_id': user_id, 
         'workspace_directory': root_directory + '/workspaces', 
         'resource_directory': root_directory + '/resources', 
         'log_directory': 'D:/github' + '/log', 
         'test_data_directory': 'D:/github' + '/test_data',
         'cache_directory': 'D:/github/w_vattenstatus/cache'}

t0 = time.time()
ekos = EventHandler(**paths)
#request = ekos.test_requests['request_workspace_list']
#response = ekos.request_workspace_list(request) 
#ekos.write_test_response('request_workspace_list', response)
print('-'*50)
print('Time for request: {}'.format(time.time()-t0))


2018-10-16 16:29:47,260	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:47,264	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:47,273	logger.py	87	add_log	DEBUG	### Log added for log_id "event_handler" at locaton: D:\github\log\main_event_handler.log
2018-10-16 16:29:47,276	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
2018-10-16 16:29:47,278	event_handler.py	117	__init__	DEBUG	Start EventHandler: event_handler
2018-10-16 16:29:47,283	event_handler.py	152	_load_mapping_objects	DEBUG	Loading mapping files from pickle file.
D:/github/w_vattenstatus/ekostat_calculator
====================================================================================================
event_handler
D:/github/log
main
----------------------------------------------------------------------------------------------------
2018-10-16 16:29:47,717	event_handler.py	128	__init__	DEBUG	Time for mapping: 0.43379998207092285
2018-10-16 16:29:47,717	event_handler.py	133	__init__	DEBUG	Time for initiating EventHandler: 0.45779991149902344
--------------------------------------------------
Time for request: 0.45779991149902344

In [3]:
###############################################################################################################################
# ### Make a new workspace

In [4]:
# ekos.copy_workspace(source_uuid='default_workspace', target_alias='kustzonsmodellen_3daydata')

In [5]:
# ### See existing workspaces and choose workspace name to load
ekos.print_workspaces()
workspace_uuid = ekos.get_unique_id_for_alias(workspace_alias = workspace_alias) #'kuszonsmodellen' lena_indicator 
print(workspace_uuid)

workspace_alias = ekos.get_alias_for_unique_id(workspace_uuid = workspace_uuid)


====================================================================================================
Current workspaces for user are:

uuid                                    alias                         status                        
----------------------------------------------------------------------------------------------------
default_workspace                       default_workspace             readable                      
e86ae1c5-d241-46a4-9236-59524b44e500    lena_indicator                editable                      
2c27da69-6035-418b-8f5e-bc8ef8e6320b    kuszonsmodellen               editable                      
78bd7584-5de1-45ca-9176-09a998a7e734    kustzonsmodellen_3daydata     editable                      
====================================================================================================
e86ae1c5-d241-46a4-9236-59524b44e500

In [6]:
###############################################################################################################################
# ### Load existing workspace
ekos.load_workspace(unique_id = workspace_uuid)


2018-10-16 16:29:52,265	event_handler.py	3070	load_workspace	DEBUG	Trying to load new workspace "e86ae1c5-d241-46a4-9236-59524b44e500" with alias "lena_indicator"
2018-10-16 16:29:52,455	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:52,455	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:52,471	logger.py	87	add_log	DEBUG	### Log added for log_id "7f201e5d-4483-4e2f-a1ea-4d1665df23dc" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\subset_7f201e5d-4483-4e2f-a1ea-4d1665df23dc.log
2018-10-16 16:29:52,471	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
2018-10-16 16:29:52,591	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:52,591	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:52,591	logger.py	87	add_log	DEBUG	### Log added for log_id "81978047-1a7a-4b9c-8acb-4a09a70f6c7d" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\subset_81978047-1a7a-4b9c-8acb-4a09a70f6c7d.log
2018-10-16 16:29:52,591	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
indicator_BQI.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/7f201e5d-4483-4e2f-a1ea-4d1665df23dc/step_2/settings/indicator_settings/
indicator_oxygen.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/7f201e5d-4483-4e2f-a1ea-4d1665df23dc/step_2/settings/indicator_settings/
====================================================================================================
7f201e5d-4483-4e2f-a1ea-4d1665df23dc
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
subset
----------------------------------------------------------------------------------------------------
indicator_BQI.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/81978047-1a7a-4b9c-8acb-4a09a70f6c7d/step_2/settings/indicator_settings/
indicator_oxygen.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/81978047-1a7a-4b9c-8acb-4a09a70f6c7d/step_2/settings/indicator_settings/
====================================================================================================
81978047-1a7a-4b9c-8acb-4a09a70f6c7d
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
subset
----------------------------------------------------------------------------------------------------
indicator_biov.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_BQI.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_chl.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_din_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_dip_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_ntot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_ntot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_oxygen.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_ptot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
indicator_ptot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
2018-10-16 16:29:53,110	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:53,142	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:53,142	logger.py	87	add_log	DEBUG	### Log added for log_id "889e11e4-1887-4dc6-8dc5-687e56494dc7" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\subset_889e11e4-1887-4dc6-8dc5-687e56494dc7.log
2018-10-16 16:29:53,142	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
indicator_secchi.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/889e11e4-1887-4dc6-8dc5-687e56494dc7/step_2/settings/indicator_settings/
====================================================================================================
889e11e4-1887-4dc6-8dc5-687e56494dc7
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
subset
----------------------------------------------------------------------------------------------------
indicator_biov.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_BQI.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_chl.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_din_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_dip_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_ntot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_ntot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_oxygen.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_ptot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
2018-10-16 16:29:53,640	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:53,640	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:53,640	logger.py	87	add_log	DEBUG	### Log added for log_id "88a513f6-9754-44b1-8b53-1d6dd0929891" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\subset_88a513f6-9754-44b1-8b53-1d6dd0929891.log
2018-10-16 16:29:53,640	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
indicator_ptot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
indicator_secchi.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/88a513f6-9754-44b1-8b53-1d6dd0929891/step_2/settings/indicator_settings/
====================================================================================================
88a513f6-9754-44b1-8b53-1d6dd0929891
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
subset
----------------------------------------------------------------------------------------------------
indicator_biov.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_BQI.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_chl.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_din_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_dip_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_ntot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_ntot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_oxygen.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_ptot_summer.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_ptot_winter.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
indicator_secchi.pkl not in D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/subsets/default_subset/step_2/settings/indicator_settings/
2018-10-16 16:29:54,953	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:54,954	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:54,954	logger.py	87	add_log	DEBUG	### Log added for log_id "default_subset" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\subset_default_subset.log
2018-10-16 16:29:54,954	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
2018-10-16 16:29:55,123	logger.py	85	add_log	DEBUG	
2018-10-16 16:29:55,123	logger.py	86	add_log	DEBUG	========================================================================================================================
2018-10-16 16:29:55,138	logger.py	87	add_log	DEBUG	### Log added for log_id "e86ae1c5-d241-46a4-9236-59524b44e500" at locaton: D:\github\w_vattenstatus\ekostat_calculator\workspaces\e86ae1c5-d241-46a4-9236-59524b44e500\log\workspace_e86ae1c5-d241-46a4-9236-59524b44e500.log
2018-10-16 16:29:55,138	logger.py	88	add_log	DEBUG	------------------------------------------------------------------------------------------------------------------------
2018-10-16 16:29:55,138	event_handler.py	3088	load_workspace	INFO	Workspace "e86ae1c5-d241-46a4-9236-59524b44e500" with alias "lena_indicator loaded."
====================================================================================================
default_subset
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
subset
----------------------------------------------------------------------------------------------------
====================================================================================================
e86ae1c5-d241-46a4-9236-59524b44e500
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/log
workspace
----------------------------------------------------------------------------------------------------
Out[6]:
True

In [7]:
###############################################################################################################################
# ### import data
# ekos.import_default_data(workspace_alias = workspace_alias)

In [8]:
###############################################################################################################################
# ### Load all data in workspace
# #### if there is old data that you want to remove
ekos.get_workspace(workspace_uuid = workspace_uuid).delete_alldata_export()
ekos.get_workspace(workspace_uuid = workspace_uuid).delete_all_export_data()


2018-10-16 16:30:08,982	workspaces.py	1525	delete_all_export_data	DEBUG	All files in export directory are deleted and all "loaded" in datatype_settings is 0.
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports\all_data.pkl
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports\all_data.txt

In [9]:
###############################################################################################################################
# #### to just load existing data in workspace
ekos.load_data(workspace_uuid = workspace_uuid)


2018-10-16 16:30:10,042	workspaces.py	1845	load_all_data	DEBUG	All selected data in (status 1 in datatype_settings.txt) is not loaded.
¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports\all_data.pkl
D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports\all_data.txt
2018-10-16 16:30:14,804	workspaces.py	1928	load_datatype_data	DEBUG	New data files has been loaded for datatype: physicalchemical
2018-10-16 16:30:14,809	workspaces.py	1928	load_datatype_data	DEBUG	New data files has been loaded for datatype: physicalchemicalmodel
2018-10-16 16:30:15,266	workspaces.py	1928	load_datatype_data	DEBUG	New data files has been loaded for datatype: chlorophyll
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/Raw_format_chlorophyll_data.txt
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/Raw_format_phytoplankton_data.txt
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/Raw_format_phytoplankton_data.txt
2018-10-16 16:30:34,320	workspaces.py	1928	load_datatype_data	DEBUG	New data files has been loaded for datatype: phytoplankton
2018-10-16 16:30:34,828	workspaces.py	1928	load_datatype_data	DEBUG	New data files has been loaded for datatype: zoobenthos
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/Raw_format_zoobenthos_data.txt
self.all_data 0
MMMMMMMMM
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/removed__before_saving_all_data.txt
D:/github/w_vattenstatus/ekostat_calculator\core\load.py:271: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  df['index_column']=df.index
time for _add_prioritized_parameter SALT is: 0.2049999237060547
time for _add_prioritized_parameter TEMP is: 0.1735999584197998
time for _add_prioritized_parameter DOXY is: 0.17440009117126465
--------------------------------------------------
Total time: 5.175800085067749
time_preparations              0.015600204467773438
time_list_group_data:          0.031199932098388672
time_list_calc_integ:          0.08099937438964844
time_list_add_row:             2.362800359725952
time_all_calculations:         4.894999980926514
time_iterator:                 0.0
time_add_data:                 0.23399996757507324
Done adding integrated_calc "CPHL_INTEG_CALC" using parameter "CPHL_BTL"
time for integrated_calc "CPHL_INTEG_CALC" using parameter "CPHL_BTL is: 5.175800085067749
Saving data to: D:/github/w_vattenstatus/ekostat_calculator/workspaces/e86ae1c5-d241-46a4-9236-59524b44e500/input_data/exports/all_data.txt
Out[9]:
True

In [10]:
############################################################################################################################### 
# ### check workspace data length
w = ekos.get_workspace(workspace_uuid = workspace_uuid)
len(w.data_handler.get_all_column_data_df())


Out[10]:
106090

In [11]:
###############################################################################################################################  
# ### see subsets in data  
for subset_uuid in w.get_subset_list():
    print('uuid {} alias {}'.format(subset_uuid, w.uuid_mapping.get_alias(unique_id=subset_uuid)))


uuid 7f201e5d-4483-4e2f-a1ea-4d1665df23dc alias test_subset
uuid 81978047-1a7a-4b9c-8acb-4a09a70f6c7d alias period_2007-2012_refvalues_2017
uuid 889e11e4-1887-4dc6-8dc5-687e56494dc7 alias period_2007-2012_refvalues_2013
uuid 88a513f6-9754-44b1-8b53-1d6dd0929891 alias period_2007-2012_refvalues_2006
uuid default_subset alias default_subset

In [12]:
###############################################################################################################################  
# # Step 0 
print(w.data_handler.all_data.columns)


Index(['AMON', 'BIOV_CONC_ALL', 'BQIm', 'CPHL_BTL', 'CPHL_INTEG', 'DEPH',
       'DIN', 'DOXY_BTL', 'DOXY_CTD', 'LATIT_DD', 'LONGI_DD', 'MNDEP', 'MXDEP',
       'MYEAR', 'NTOT', 'NTRA', 'NTRI', 'NTRZ', 'PHOS', 'PTOT', 'Q_AMON',
       'Q_BIOV_CONC_ALL', 'Q_BQIm', 'Q_CPHL_BTL', 'Q_CPHL_INTEG', 'Q_DOXY_BTL',
       'Q_DOXY_CTD', 'Q_NTOT', 'Q_NTRA', 'Q_NTRI', 'Q_NTRZ', 'Q_PHOS',
       'Q_PTOT', 'Q_SALT_BTL', 'Q_SALT_CTD', 'Q_SECCHI', 'Q_TEMP_BTL',
       'Q_TEMP_CTD', 'RLABO', 'SALT_BTL', 'SALT_CTD', 'SDATE', 'SEA_BASIN',
       'SECCHI', 'SERNO', 'SHARKID_MD5', 'SHIPC', 'STATN', 'STIME', 'TEMP_BTL',
       'TEMP_CTD', 'VISS_EU_CD', 'WADEP', 'WATER_BODY_NAME', 'WATER_DISTRICT',
       'WATER_TYPE_AREA', 'WLTYP', 'origin_dtype', 'origin_file_path', 'MONTH',
       'YEAR', 'POSITION', 'visit_id_str', 'date', 'SALT', 'Q_SALT',
       'source_SALT', 'TEMP', 'Q_TEMP', 'source_TEMP', 'DOXY', 'Q_DOXY',
       'source_DOXY', 'CPHL_INTEG_CALC', 'CPHL_INTEG_CALC_depths',
       'CPHL_INTEG_CALC_values', 'index_column'],
      dtype='object')

In [13]:
###############################################################################################################################    
# ### Apply first data filter 
w.apply_data_filter(step = 0) # This sets the first level of data filter in the IndexHandler

In [14]:
###############################################################################################################################  
# # Step 1 
# ### make new subset
# w.copy_subset(source_uuid='default_subset', target_alias='test_kustzon')

In [15]:
###############################################################################################################################
# ### Choose subset name to load
subset_alias = 'test_subset'
subset_uuid = ekos.get_unique_id_for_alias(workspace_alias = workspace_alias, subset_alias = subset_alias)
print('subset_alias', subset_alias, 'subset_uuid', subset_uuid)


subset_alias test_subset subset_uuid 7f201e5d-4483-4e2f-a1ea-4d1665df23dc
#

Set subset filters


In [16]:
# #### year filter
w.set_data_filter(subset = subset_uuid, step=1, 
                         filter_type='include_list', 
                         filter_name='MYEAR', 
                         data=[2007,2008,2009,2010,2011,2012])#['2011', '2012', '2013']) #, 2014, 2015, 2016


Out[16]:
True

In [17]:
###############################################################################################################################
# #### waterbody filter
w.set_data_filter(subset = subset_uuid, step=1, 
                         filter_type='include_list', 
                         filter_name='viss_eu_cd', data = []) #'SE584340-174401', 'SE581700-113000', 'SE654470-222700', 'SE633000-195000', 'SE625180-181655'
#                          data=['SE584340-174401', 'SE581700-113000', 'SE654470-222700', 'SE633000-195000', 'SE625180-181655']) 
#                          wb with no data for din 'SE591400-182320'
  
f1 = w.get_data_filter_object(subset = subset_uuid, step=1) 
print(f1.include_list_filter)

print('subset_alias:', subset_alias, '\nsubset uuid:', subset_uuid)

f1 = w.get_data_filter_object(subset = subset_uuid, step=1) 
print(f1.include_list_filter)


{'MYEAR': ['2007', '2008', '2009', '2010', '2011', '2012'], 'STATN': [], 'VISS_EU_CD': []}
subset_alias: test_subset 
subset uuid: 7f201e5d-4483-4e2f-a1ea-4d1665df23dc
{'MYEAR': ['2007', '2008', '2009', '2010', '2011', '2012'], 'STATN': [], 'VISS_EU_CD': []}

In [19]:
###############################################################################################################################    
# ## Apply step 1 datafilter to subset
w.apply_data_filter(subset = subset_uuid, step = 1)
filtered_data = w.get_filtered_data(step = 1, subset = subset_uuid)
#print(filtered_data['VISS_EU_CD'].unique())

In [20]:
filtered_data[['AMON','NTRA','DIN','CPHL_INTEG_CALC','DEPH']].head()


Out[20]:
AMON NTRA DIN CPHL_INTEG_CALC DEPH
1226 NaN NaN NaN NaN NaN
1227 NaN NaN NaN NaN NaN
1228 NaN NaN NaN NaN NaN
1229 NaN NaN NaN NaN NaN
1230 NaN NaN NaN NaN NaN
#

Step 2


In [21]:
### Load indicator settings filter 
w.get_step_object(step = 2, subset = subset_uuid).load_indicator_settings_filters()

In [22]:
############################################################################################################################### 
### set available indicators  
w.get_available_indicators(subset= subset_uuid, step=2)


['TOT_COVER_ALL', 'SALT'] not in filtered_data
Out[22]:
['indicator_din_winter',
 'indicator_ntot_summer',
 'indicator_ntot_winter',
 'indicator_dip_winter',
 'indicator_ptot_summer',
 'indicator_ptot_winter',
 'indicator_bqi',
 'indicator_oxygen',
 'indicator_biov',
 'indicator_chl',
 'indicator_secchi']

In [23]:
###############################################################################################################################
# ### choose indicators
#list(zip(typeA_list, df_step1.WATER_TYPE_AREA.unique()))
# indicator_list = ['oxygen','din_winter','ntot_summer', 'ntot_winter', 'dip_winter', 'ptot_summer', 'ptot_winter','bqi', 'biov', 'chl', 'secchi']
# indicator_list = ['din_winter','ntot_summer', 'ntot_winter', 'dip_winter', 'ptot_summer', 'ptot_winter']
#indicator_list = ['biov', 'chl']
# indicator_list = ['bqi', 'biov', 'chl', 'secchi']
#indicator_list = ['bqi', 'secchi'] + ['biov', 'chl'] + ['din_winter']
# indicator_list = ['din_winter','ntot_summer']
# indicator_list = ['indicator_' + indicator for indicator in indicator_list]
indicator_list = w.available_indicators

In [24]:
###############################################################################################################################  
# ### Apply indicator data filter
print('apply indicator data filter to {}'.format(indicator_list))
for indicator in indicator_list:
    w.apply_indicator_data_filter(step = 2, 
                          subset = subset_uuid, 
                          indicator = indicator)#,
#                         water_body_list = test_wb)
    #print(w.mapping_objects['water_body'][wb])
    #print('*************************************')

#df = w.get_filtered_data(subset = subset_uuid, step = 'step_2', water_body = 'SE625180-181655', indicator = 'indicator_din_winter').dropna(subset = ['DIN'])


apply indicator data filter to ['indicator_din_winter', 'indicator_ntot_summer', 'indicator_ntot_winter', 'indicator_dip_winter', 'indicator_ptot_summer', 'indicator_ptot_winter', 'indicator_bqi', 'indicator_oxygen', 'indicator_biov', 'indicator_chl', 'indicator_secchi']
--------------------------------------------------
Total time to apply data filters for indicator indicator_din_winter: 13.444600105285645
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_ntot_summer: 8.760999917984009
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_ntot_winter: 9.140599966049194
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_dip_winter: 9.109999895095825
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_ptot_summer: 10.625999927520752
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_ptot_winter: 10.224200010299683
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_bqi: 8.458200216293335
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_oxygen: 7.14300012588501
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_biov: 9.237800121307373
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_chl: 9.260600090026855
--------------------------------------------------
--------------------------------------------------
Total time to apply data filters for indicator indicator_secchi: 10.283400297164917
--------------------------------------------------
#

Step 3


In [25]:
# ### Set up indicator objects
print('indicator set up to {}'.format(indicator_list))
w.get_step_object(step = 3, subset = subset_uuid).indicator_setup(indicator_list = indicator_list)


indicator set up to ['indicator_din_winter', 'indicator_ntot_summer', 'indicator_ntot_winter', 'indicator_dip_winter', 'indicator_ptot_summer', 'indicator_ptot_winter', 'indicator_bqi', 'indicator_oxygen', 'indicator_biov', 'indicator_chl', 'indicator_secchi']
****INITIATING INDICATOR OBJECT FOR****
indicator_din_winter
D:/github/w_vattenstatus/ekostat_calculator\core\filters.py:1488: RuntimeWarning: invalid value encountered in less
  salinity[salinity < 2] = 2
D:/github/w_vattenstatus/ekostat_calculator\core\filters.py:1489: RuntimeWarning: invalid value encountered in greater
  salinity[salinity > max_s] = max_s
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-3aa377e79acc> in <module>()
      1 # ### Set up indicator objects
      2 print('indicator set up to {}'.format(indicator_list))
----> 3 w.get_step_object(step = 3, subset = subset_uuid).indicator_setup(indicator_list = indicator_list)

D:/github/w_vattenstatus/ekostat_calculator\core\workspaces.py in indicator_setup(self, indicator_list)
    422             self.indicator_objects[indicator] = class_(subset_uuid = subset_unique_id, 
    423                                                                       parent_workspace_object = self.parent_workspace_object,
--> 424                                                                       indicator = indicator)
    425             time_ind = time.time() - t_start
    426             print('-'*50)

D:/github/w_vattenstatus/ekostat_calculator\core\indicators.py in __init__(self, subset_uuid, parent_workspace_object, indicator)
   1219         self.salt_parameter = self.parameter_list[-1]
   1220         # Set dataframe to use
-> 1221         self._set_water_body_indicator_df(water_body = None)
   1222 
   1223     def _add_winter_year(self, df, winter_months):

D:/github/w_vattenstatus/ekostat_calculator\core\indicators.py in f(*args, **kwargs)
     21     def f(*args, **kwargs):
     22         from_time = time.time()
---> 23         rv = func(*args, **kwargs)
     24         to_time = time.time()
     25         print('"{.__name__}". Time for running method was {}'.format(func, to_time-from_time))

D:/github/w_vattenstatus/ekostat_calculator\core\indicators.py in _set_water_body_indicator_df(self, water_body)
    631             if self.name != 'indicator_oxygen':
    632 #                 print('this is where the SettingCopyWithWarning is raised!!!')
--> 633                 self._add_boundaries_to_df(df, water_body)
    634             self.water_body_indicator_df[water_body] = df
    635 

D:/github/w_vattenstatus/ekostat_calculator\core\indicators.py in _add_boundaries_to_df(self, df, water_body)
    208                 df.loc[:,'PB_VALUE_LIMIT'] = [item*PB_EQR_LIMIT for item in  ref_list]
    209             elif self.direction_good == 'negative':
--> 210                 df.loc[:,'HG_VALUE_LIMIT'] = [item/HG_EQR_LIMIT for item in  ref_list]
    211                 df.loc[:,'GM_VALUE_LIMIT'] = [item/GM_EQR_LIMIT for item in  ref_list]
    212                 df.loc[:,'MP_VALUE_LIMIT'] = [item/MP_EQR_LIMIT for item in  ref_list]

D:/github/w_vattenstatus/ekostat_calculator\core\indicators.py in <listcomp>(.0)
    208                 df.loc[:,'PB_VALUE_LIMIT'] = [item*PB_EQR_LIMIT for item in  ref_list]
    209             elif self.direction_good == 'negative':
--> 210                 df.loc[:,'HG_VALUE_LIMIT'] = [item/HG_EQR_LIMIT for item in  ref_list]
    211                 df.loc[:,'GM_VALUE_LIMIT'] = [item/GM_EQR_LIMIT for item in  ref_list]
    212                 df.loc[:,'MP_VALUE_LIMIT'] = [item/MP_EQR_LIMIT for item in  ref_list]

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

In [41]:
###############################################################################################################################
# ### CALCULATE STATUS
print('CALCULATE STATUS to {}'.format(indicator_list))
w.get_step_object(step = 3, subset = subset_uuid).calculate_status(indicator_list = indicator_list)


CALCULATE STATUS to []

In [ ]:
###############################################################################################################################  
# ### CALCULATE QUALITY ELEMENTS
w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(quality_element = 'nutrients')
# w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(quality_element = 'phytoplankton')
# w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(quality_element = 'bottomfauna')
# w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(quality_element = 'oxygen')
# w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(quality_element = 'secchi')
 
# w.get_step_object(step = 3, subset = subset_uuid).calculate_quality_element(subset_unique_id = subset_uuid, quality_element = 'Phytoplankton')