<jupyter_start><jupyter_text>Mass Flow Correction Factor lookup table scraper - <NAME>this is a auxiliary script set to conveniently collect the correction factor lookup table for both thermal and ion mass flow controllers by scraping via pandas the correction table from MKS instruments https://www.mksinst.com/docs/ur/MFCGasCorrection.aspxthe results from the scraping and post processing are used in the program in the jupyter notebook `IONTech GFC-1000` Note that the correction factors from MKS do differ somewhat from those listed in the manual for the the Ion Tech GFC-1000 but not significantly enough  to warrant transcribing those tables to code<jupyter_code>import pandas as pd

def StrNumtoFloat(x):
    """
    convince function use with Pandas.apply for converting string encoded 
    numerical values to floats with two decimal place precision
    
    Args:
        x (str): input that is attempted to be converted to a float typically
         will be a string
    
    Returns:
        x (float) if the x input is capable of being converted to float
        
        x  as what passed to this function if the x input was not capable of 
        being converted to a float
    """
    try:
        return format(float(x), '.2f')
    except ValueError:
        return x<jupyter_output><empty_output><jupyter_text>Thermal Mass Flow Correction Factors<jupyter_code># Scraping target site
ThermalMassFlowCorrectionMKSTar='https://www.mksinst.com/docs/ur/MFCGasCorrection.aspx'
#scrap that target site and get the appropriate table from target
MFThermalCorrDF=pd.read_html(ThermalMassFlowCorrectionMKSTar)[1]
MFThermalCorrDF
#remove the unnecessary columns
MFThermalCorrDF.drop([1, 2, 3], axis=1, inplace=True)

#rename columns to first row entries, remove said rows, reindex
MFThermalCorrDF.columns=MFThermalCorrDF.iloc[0]
MFThermalCorrDF.drop([0], axis=0, inplace=True)
MFThermalCorrDF.reindex()

#redo the indexing to start at 1
MFThermalCorrDF.drop([MFThermalCorrDF.shape[0]], axis=0, inplace=True)
MFThermalCorrDF
#convert the conversion  factor that is currently a str in table to a float
for i in ['ConversionFactor']:
    MFThermalCorrDF[i]=MFThermalCorrDF[i].apply(StrNumtoFloat)
MFThermalCorrDF
# Remove any rows where the conversion factor as a string did not convert to 
# a float
MFThermalCorrDF=MFThermalCorrDF.where(MFThermalCorrDF['ConversionFactor'].apply(lambda x: type(x))==float)
MFThermalCorrDF.dropna(axis=0, how='any', inplace=True)
MFThermalCorrDF
for i in ['ConversionFactor']:
    MFThermalCorrDF[i]=MFThermalCorrDF[i].apply(StrNumtoFloat)
MFThermalCorrDF
# reset the index to the gas name
MFThermalCorrDF.index=MFThermalCorrDF['Gas']
MFThermalCorrDF.drop(['Gas'], axis=1, inplace=True)
MFThermalCorrDF
float(MFThermalCorrDF.loc['Nitrogen'])
# pickle the thermal mass flow controller dataframe to use in other programs
MFThermalCorrDF.to_pickle('MFThermalCorrDF.p')
MFThermalCorrDic={}
for _, row in MFThermalCorrDF.iterrows():
    MFThermalCorrDic[row['Gas']]=row['ConversionFactor']
MFThermalCorrDic<jupyter_output><empty_output><jupyter_text>Ion Mass Flow Correction Factors<jupyter_code>IonMassFlowCorrectionMKSTar='https://www.mksinst.com/docs/ur/GaugeGasCorrection.aspx'
MFIonCorrDF=pd.read_html(ThermalMassFlowCorrectionMKSTar)[1]
MFIonCorrDF
MFIonCorrDF.drop([1], axis=1, inplace=True)
MFIonCorrDF.columns=MFIonCorrDF.iloc[0]
MFIonCorrDF.drop([0], axis=0, inplace=True)
MFIonCorrDF.reindex()
MFIonCorrDF['Gas Correction Factor']=MFIonCorrDF['Gas Correction Factor'].apply(StrNumtoFloat)
MFIonCorrDF
MFIonCorrDic={}
for _, row in MFIonCorrDF.iterrows():
    MFIonCorrDic[row['Gas']]=row['Gas Correction Factor']
MFIonCorrDic<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0851581508515815, 'fraction_numerical': 0.007569613409029468, 'mean_word_length': 5.8645640074211505, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 3, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '299193', 'license': 'MIT', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1248, 'n_words': 341, 'path': 'MassFlowCFFinder.ipynb', 'repo_name': 'PyLCARS/PyEEInstrumentationSansVISA', 'size': '3708'}