Beispiel #1
0
 def saveCondData(self, dat):
     '''Save final data array'''
     if self.mainWindow.checkBoxSave.isChecked():
         self.inputManager.loc['setup'].value = str('Conductivity')
         Utilities.conductivity_save_to_file(self.inputManager, dat[0], dat[1], dat[2], dat[3])
     else:
         print ('### Data has not been saved. ###')    
Beispiel #2
0
 def saveIVData(self, dat):
     '''Save final data array'''
     if self.mainWindow.checkBoxSave.isChecked():
         self.inputManager.loc['setup'].value = str('IV_sweep')
         Utilities.save_to_file(self.inputManager, dat[0], dat[1])
     else:
         print ('### Data has not been saved. ###')
Beispiel #3
0
 def restoreState(self):
     ''' write inputManager values to user input widgets.
             input widget values saved on close to inputManager csv'''
     try:
         self.inputManager = pd.DataFrame.from_csv('src/df_measurement.csv', header = 1)
         for w in self.inputWidgets:
             field = w.accessibleName()
             if not (str(field) == 'exp_name' or str(field) == 'sample'):
                 if self.inputManager.loc[field].value != None:
                     Utilities.setWidgetValue(w, self.inputManager.loc[field].value)
     except:
         pass           
Beispiel #4
0
    def _get_master(self):
        """ Get the global dataset that will be used for all calculations inside
        this instance of the class

        :return: None
        """
        start_time = time.time()
        start_date, end_date = self._get_date(None,
                                              self.start_date), self._get_date(
                                                  None, self.end_date)
        query = Utilities.open_sql(self.dir_path, 'user_sequence.sql')

        # Temp fix for testing because my credentials are not working
        cache = False
        if cache:
            df = pd.read_csv(
                os.path.join(self.dir_path, 'data/manually_loaded_data',
                             'United Kingdom-Customer Service.csv'))
            print("Converting object types...")
            df = df.astype({'time_event': 'datetime64[ns]'})
            df['time_event'] = df.time_event.apply(
                lambda x: pytz.utc.localize(x))
            df['date'] = df.time_event.dt.date
            self.master = df
        else:
            self.master = self.query_db(query, self._formatted_flow_name(),
                                        start_date.strftime('%Y-%m-%d'),
                                        end_date.strftime('%Y-%m-%d'))
        print(
            f"Master Dataset Gathered in {round(time.time() - start_time, 0)} seconds"
        )
Beispiel #5
0
def recover_password(email: str, db: Session = Depends(crud.get_db)) -> Any:
    """
    Password Recovery
    """

    from_email = settings.FROM_EMAIL
    user = crud.get_user_by_email(db, email=email)

    if not user:
        raise HTTPException(
            status_code=404,
            detail="The user with this username does not exist in the system.",
        )
    password_reset_token = Utilities.generate_password_reset_token(email=email)

    Utilities.send_reset_password_email(email_to=user.email,
                                        email=from_email,
                                        token=password_reset_token)
    return {"msg": "Password recovery email sent"}
Beispiel #6
0
 def parse_ips_from_file(self, file_name):
     log.debug("Running function \"%s\"" % self.parse_ips_from_file.__name__)
     set_of_ip_address = set()
     with open(file_name, 'r') as open_file:
         # Find each ip address in line
         for line in open_file:
             found_ip_address_list = re.findall("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", line)
             # Put each ip address into a set to avoid duplicates
             for found_ip_address in found_ip_address_list:
                 log.debug("Potential IP Address \"%s\" found" % found_ip_address)
                 # Validate ip address
                 if Utilities.is_valid_ip_address(found_ip_address):
                     set_of_ip_address.add(found_ip_address)
     # Input sorted set of ip addresses into list of IPAddressData
     for ip_address in sorted(set_of_ip_address):
         self.ip_address_data_list.append(IPAddressData(ip_address))
Beispiel #7
0
 def __init__(self, project_id: str) -> None:
     self.project_id = project_id
     self.client = Utilities.get_bigquery_client(project_id)
Beispiel #8
0
 def get_available_flows(self):
     query = Utilities.open_sql(self.dir_path, 'flownames.sql')
     df = self.client.query(query).to_dataframe()
     return df['FlowName'].to_list()
Beispiel #9
0
 def get_ip_address_with_search_parameters(self, search_dictionary):
     ip_addresses_that_match = list()
     for item in self.ip_address_data_list:
         if Utilities.is_dict_all_true(Utilities.get_search_recursively(item.ip_data, search_dictionary, None)):
             ip_addresses_that_match.append(item.ip_address)
     return '\n'.join(str(item) for item in ip_addresses_that_match)
Beispiel #10
0
 def get_ip_data_keys(self):
     set_of_keys = set()
     for item in self.ip_address_data_list:
         set_of_keys = set_of_keys.union(Utilities.get_keys_recursively(item.ip_data))
     self.search_keys = sorted(self.search_keys.union(set_of_keys))
Beispiel #11
0
 def saveDepositionData(self, dat):
     '''Save final data array'''
     if self.mainWindow.checkBoxSave.isChecked():
         Utilities.deposition_save_to_file(self.inputManager, dat[0], dat[1], dat[2], dat[3], dat[4], dat[5], dat[6], dat[7], dat[8])
     else:
         print ('### Data has not been saved. ###')    
Beispiel #12
0
    def getInputs(self):
        '''get measurement parameters from GUI and store in dataframe.'''

        for w in self.inputWidgets:
            try:
                self.inputManager.loc[str(w.accessibleName())].value = Utilities.getWidgetValue(w)
            except:
                print ('Input parameter error: ', w.objectName())
            else:
                pass
        
        self.inputManager.loc['date'].value = str(datetime.datetime.now())
        self.inputManager.loc['user'].value = str(getpass.getuser())
        self.inputManager.loc['vers'].value = __version__
        
        if self.mainWindow.checkBox_IV.isChecked() == True and self.mainWindow.checkBox_fixedV.isChecked() == True:
            self.inputManager.loc['setup'].value = str('Conductivity')
        
        if self.mainWindow.checkBox_IV.isChecked() == True and self.mainWindow.checkBox_fixedV.isChecked() == False:
            self.inputManager.loc['setup'].value = str('IVsweep')
            self.inputManager.loc['fixedV'].value = None
            self.inputManager.loc['nRepeats'].value = None
            self.inputManager.loc['pauseTime'].value = None
            
            
        if self.mainWindow.checkBox_IV.isChecked() == False and self.mainWindow.checkBox_fixedV.isChecked() == True:
            self.inputManager.loc['setup'].value = str('FixedV')
            self.inputManager.loc['initialV'].value = None
            self.inputManager.loc['finalV'].value = None
            self.inputManager.loc['stepSize'].value = None           
            self.inputManager.loc['holdTime'].value = None            
            self.inputManager.loc['x_descript'].value = str('Sample')            
            self.inputManager.loc['x_descript'].units = None     
            
        if self.mainWindow.checkBox_IV.isChecked() == False and self.mainWindow.checkBox_fixedV.isChecked() == False:
            self.inputManager.loc['setup'].value = str('DepositionMonitoring')
            self.inputManager.loc['fixedV'].value = None
            self.inputManager.loc['nRepeats'].value = None
            self.inputManager.loc['pauseTime'].value = None
            self.inputManager.loc['initialV'].value = None
            self.inputManager.loc['finalV'].value = None
            self.inputManager.loc['stepSize'].value = None           
            self.inputManager.loc['holdTime'].value = None            
            self.inputManager.loc['x_descript'].value = str('Time')  
            self.inputManager.loc['x_descript'].units = str('s')
            self.inputManager.loc['y_descript'].value = str('QCM1 thickness, QCM1 rate, QCM2 thickness, QCM2 rate, etc.')                
            self.inputManager.loc['y_descript'].units = str('') 
            
        # For transistor picture  
        if self.mainWindow.OFET_20_1.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(20)
            self.inputManager.loc['OFET_no'].value = int(1)
        if self.mainWindow.OFET_20_2.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(20)
            self.inputManager.loc['OFET_no'].value = int(2)
        if self.mainWindow.OFET_20_3.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(20)
            self.inputManager.loc['OFET_no'].value = int(3)  
        if self.mainWindow.OFET_20_4.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(20)
            self.inputManager.loc['OFET_no'].value = int(4)
        if self.mainWindow.OFET_10_1.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(10)
            self.inputManager.loc['OFET_no'].value = int(1)
        if self.mainWindow.OFET_10_2.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(10)
            self.inputManager.loc['OFET_no'].value = int(2)
        if self.mainWindow.OFET_10_3.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(10)
            self.inputManager.loc['OFET_no'].value = int(3)  
        if self.mainWindow.OFET_10_4.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(10)
            self.inputManager.loc['OFET_no'].value = int(4)      
        if self.mainWindow.OFET_5_1.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(5)
            self.inputManager.loc['OFET_no'].value = int(1)
        if self.mainWindow.OFET_5_2.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(5)
            self.inputManager.loc['OFET_no'].value = int(2)
        if self.mainWindow.OFET_5_3.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(5)
            self.inputManager.loc['OFET_no'].value = int(3)  
        if self.mainWindow.OFET_5_4.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = int(5)
            self.inputManager.loc['OFET_no'].value = int(4)         
        if self.mainWindow.OFET_2p5_1.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = float(2.5)
            self.inputManager.loc['OFET_no'].value = int(1)
        if self.mainWindow.OFET_2p5_2.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = float(2.5)
            self.inputManager.loc['OFET_no'].value = int(2)
        if self.mainWindow.OFET_2p5_3.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = float(2.5)
            self.inputManager.loc['OFET_no'].value = int(3)  
        if self.mainWindow.OFET_2p5_4.isChecked() == True:
            self.inputManager.loc['OFET_width'].value = float(2.5)
            self.inputManager.loc['OFET_no'].value = int(4)             
        
        #self.inputManager.loc['OFET_chip'].value = 'OFET_'+str(self.inputManager.value['OFET_width'])+'_'+str(self.inputManager.value['OFET_no'])
        
        if self.inputManager.loc['exp_name'].value == None:
            pass # what to do if user forgets to put in exp name/sample???
            
        mainWindow.saveState(self)
Beispiel #13
0
import pandas as pd
import datetime
from typing import Tuple, Optional, Union, List, Dict, Any
import plotly.graph_objects as go
import pytz
import plotly.express as px
from plotly.subplots import make_subplots
import time
from anycache import anycache

from src import SankeyFlow
from src import Utilities

# credential_path = "/home/kerri/bigquery-jaya-consultant-cosmic-octane-88917-c46ba9b53a3b.json"
project_id = 'cosmic-octane-88917'
client = Utilities.get_bigquery_client(project_id)


class Flow(SankeyFlow):
    dir_path = os.path.dirname(os.path.realpath(__file__))

    def __init__(self,
                 flow_name: str,
                 start_date: datetime.date = None,
                 end_date: datetime.date = None,
                 include_tollfree=False) -> None:
        super().__init__()
        self._flow_name = flow_name
        self.start_date = start_date if start_date is not None else (
            datetime.datetime.strptime('2020-01-01', '%Y-%m-%d').date())
        self.end_date = end_date if end_date is not None else datetime.date.today(