
import numpy as np


# SCATTERING LENGTH DATA
# ----------------------------------------------------------------------------
fin = open("scattering_data.txt", "r")
field_list = []
data1_list = []
for line in fin:
    columns = line.split()
    field_list.append(float(columns[5:6][0]))
    data1_list.append(float(columns[11:12][0]))
fin.close()

convert = np.asarray(data1_list)    
y4 = convert.copy()
y4[convert > 300] = np.nan
# ----------------------------------------------------------------------------




# THRESHOLD ENERGIES
# ----------------------------------------------------------------------------
fin = open("aa_threshold.txt", "r")
energy_1_list = []
for line in fin:
    columns = line.split()
    energy_1_list.append(float(columns[3:4][0])-(-6278.12170297))
fin.close()
# ----------------------------------------------------------------------------


# BOUND STATE ENERGIES
# NEED TO OUTPUT DATA IN ABSOLUTE AND RELATIVE FORMS
# EXTRACT DATA AND CONVERT 

# field values every 2G
field_values = np.arange(0,1402,2).tolist()


# MF4 (L=0)
# ----------------------------------------------------------------------------
field_list_312 = []
data_list_312  = []
field_list_311 = []
data_list_311  = []
field_list_310 = []
data_list_310  = []
field_list_309 = []
data_list_309  = []
field_list_308 = []
data_list_308  = []
field_list_307 = []
data_list_307  = []
field_list_306 = []
data_list_306  = []

fin = open("data_L0_mf4.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['312,']:
        field_list_312.append(float(columns[5:6][0]))
        data_list_312.append(float(columns[12:13][0]))
    if columns[1:2] == ['311,']:
        field_list_311.append(float(columns[5:6][0]))
        data_list_311.append(float(columns[12:13][0]))
    if columns[1:2] == ['310,']:
        field_list_310.append(float(columns[5:6][0]))
        data_list_310.append(float(columns[12:13][0])) 
    if columns[1:2] == ['309,']:
        field_list_309.append(float(columns[5:6][0]))
        data_list_309.append(float(columns[12:13][0]))  
    if columns[1:2] == ['308,']:
        field_list_308.append(float(columns[5:6][0]))
        data_list_308.append(float(columns[12:13][0]))  
    if columns[1:2] == ['307,']:
        field_list_307.append(float(columns[5:6][0]))
        data_list_307.append(float(columns[12:13][0]))
    if columns[1:2] == ['306,']:
        field_list_306.append(float(columns[5:6][0]))
        data_list_306.append(float(columns[12:13][0]))
fin.close()

 
# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_312 = []
data_output_311 = []
data_output_310 = []
data_output_309 = []
data_output_308 = []
data_output_307 = []
data_output_306 = []
for N in range(len(field_values)):
    for i in range(len(data_list_312)):
        if (field_values[N] == field_list_312[i]):
            result = data_list_312[i] + energy_1_list[N]
            data_output_312.append(result)
    for i in range(len(data_list_311)):
        if (field_values[N] == field_list_311[i]):
            result = data_list_311[i] + energy_1_list[N]
            data_output_311.append(result)
    for i in range(len(data_list_310)):
        if (field_values[N] == field_list_310[i]):
            result = data_list_310[i] + energy_1_list[N]
            data_output_310.append(result)
    for i in range(len(data_list_309)):
        if (field_values[N] == field_list_309[i]):
            result = data_list_309[i] + energy_1_list[N]
            data_output_309.append(result)
    for i in range(len(data_list_308)):
        if (field_values[N] == field_list_308[i]):
            result = data_list_308[i] + energy_1_list[N]
            data_output_308.append(result)
    for i in range(len(data_list_307)):
        if (field_values[N] == field_list_307[i]):
            result = data_list_307[i] + energy_1_list[N]
            data_output_307.append(result)
    for i in range(len(data_list_306)):
        if (field_values[N] == field_list_306[i]):
            result = data_list_306[i] + energy_1_list[N]
            data_output_306.append(result)
# ----------------------------------------------------------------------------


# MF2
# ----------------------------------------------------------------------------
field_list_601 = []
data_list_601  = []
field_list_600 = []
data_list_600  = []
field_list_599 = []
data_list_599  = []
field_list_598 = []
data_list_598  = []
field_list_597 = []
data_list_597  = []
field_list_596 = []
data_list_596  = []
field_list_595 = []
data_list_595  = []
field_list_594 = []
data_list_594  = []
field_list_593 = []
data_list_593  = []
field_list_592 = []
data_list_592  = []
field_list_591 = []
data_list_591  = []
field_list_590 = []
data_list_590  = []
field_list_589 = []
data_list_589  = []
field_list_588 = []
data_list_588  = []
field_list_587 = []
data_list_587  = []
field_list_602 = []
data_list_602  = []
field_list_603 = []
data_list_603  = []

fin = open("data_mf2.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['603,']:
        field_list_603.append(float(columns[5:6][0]))
        data_list_603.append(float(columns[12:13][0]))
    if columns[1:2] == ['602,']:
        field_list_602.append(float(columns[5:6][0]))
        data_list_602.append(float(columns[12:13][0]))
    if columns[1:2] == ['601,']:
        field_list_601.append(float(columns[5:6][0]))
        data_list_601.append(float(columns[12:13][0]))
    if columns[1:2] == ['600,']:
        field_list_600.append(float(columns[5:6][0]))
        data_list_600.append(float(columns[12:13][0]))
    if columns[1:2] == ['599,']:
        field_list_599.append(float(columns[5:6][0]))
        data_list_599.append(float(columns[12:13][0]))  
    if columns[1:2] == ['598,']:
        field_list_598.append(float(columns[5:6][0]))
        data_list_598.append(float(columns[12:13][0]))  
    if columns[1:2] == ['597,']:
        field_list_597.append(float(columns[5:6][0]))
        data_list_597.append(float(columns[12:13][0]))  
    if columns[1:2] == ['596,']:
        field_list_596.append(float(columns[5:6][0]))
        data_list_596.append(float(columns[12:13][0]))  
    if columns[1:2] == ['595,']:
        field_list_595.append(float(columns[5:6][0]))
        data_list_595.append(float(columns[12:13][0]))  
    if columns[1:2] == ['594,']:
        field_list_594.append(float(columns[5:6][0]))
        data_list_594.append(float(columns[12:13][0]))
    if columns[1:2] == ['593,']:
        field_list_593.append(float(columns[5:6][0]))
        data_list_593.append(float(columns[12:13][0]))
    if columns[1:2] == ['592,']:
        field_list_592.append(float(columns[5:6][0]))
        data_list_592.append(float(columns[12:13][0])) 
    if columns[1:2] == ['591,']:
        field_list_591.append(float(columns[5:6][0]))
        data_list_591.append(float(columns[12:13][0]))  
    if columns[1:2] == ['590,']:
        field_list_590.append(float(columns[5:6][0]))
        data_list_590.append(float(columns[12:13][0]))
    if columns[1:2] == ['589,']:
        field_list_589.append(float(columns[5:6][0]))
        data_list_589.append(float(columns[12:13][0]))  
    if columns[1:2] == ['588,']:
        field_list_588.append(float(columns[5:6][0]))
        data_list_588.append(float(columns[12:13][0]))  
    if columns[1:2] == ['587,']:
        field_list_587.append(float(columns[5:6][0]))
        data_list_587.append(float(columns[12:13][0]))  
        
fin.close()
  
# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_603 = []
data_output_602 = []
data_output_601 = []
data_output_600 = []
data_output_599 = []
data_output_598 = []
data_output_597 = []
data_output_596 = []
data_output_595 = []
data_output_594 = []
data_output_593 = []
data_output_592 = []
data_output_591 = []
data_output_590 = []
data_output_589 = []
data_output_588 = []
data_output_587 = []
for N in range(len(field_values)):
    for i in range(len(data_list_603)):
        if (field_values[N] == field_list_603[i]):
            result = data_list_603[i] + energy_1_list[N]
            data_output_603.append(result)
    for i in range(len(data_list_602)):
        if (field_values[N] == field_list_602[i]):
            result = data_list_602[i] + energy_1_list[N]
            data_output_602.append(result)
    for i in range(len(data_list_601)):
        if (field_values[N] == field_list_601[i]):
            result = data_list_601[i] + energy_1_list[N]
            data_output_601.append(result)   
    for i in range(len(data_list_600)):
        if (field_values[N] == field_list_600[i]):
            result = data_list_600[i] + energy_1_list[N]
            data_output_600.append(result)
    for i in range(len(data_list_599)):
        if (field_values[N] == field_list_599[i]):
            result = data_list_599[i] + energy_1_list[N]
            data_output_599.append(result)
    for i in range(len(data_list_598)):
        if (field_values[N] == field_list_598[i]):
            result = data_list_598[i] + energy_1_list[N]
            data_output_598.append(result)
    for i in range(len(data_list_597)):
        if (field_values[N] == field_list_597[i]):
            result = data_list_597[i] + energy_1_list[N]
            data_output_597.append(result) 
    for i in range(len(data_list_596)):
        if (field_values[N] == field_list_596[i]):
            result = data_list_596[i] + energy_1_list[N]
            data_output_596.append(result)       
    for i in range(len(data_list_595)):
        if (field_values[N] == field_list_595[i]):
            result = data_list_595[i] + energy_1_list[N]
            data_output_595.append(result)
    for i in range(len(data_list_594)):
        if (field_values[N] == field_list_594[i]):
            result = data_list_594[i] + energy_1_list[N]
            data_output_594.append(result)
    for i in range(len(data_list_593)):
        if (field_values[N] == field_list_593[i]):
            result = data_list_593[i] + energy_1_list[N]
            data_output_593.append(result)
    for i in range(len(data_list_592)):
        if (field_values[N] == field_list_592[i]):
            result = data_list_592[i] + energy_1_list[N]
            data_output_592.append(result)
    for i in range(len(data_list_591)):
        if (field_values[N] == field_list_591[i]):
            result = data_list_591[i] + energy_1_list[N]
            data_output_591.append(result)
    for i in range(len(data_list_590)):
        if (field_values[N] == field_list_590[i]):
            result = data_list_590[i] + energy_1_list[N]
            data_output_590.append(result)
    for i in range(len(data_list_589)):
        if (field_values[N] == field_list_589[i]):
            result = data_list_589[i] + energy_1_list[N]
            data_output_589.append(result)
    for i in range(len(data_list_588)):
        if (field_values[N] == field_list_588[i]):
            result = data_list_588[i] + energy_1_list[N]
            data_output_588.append(result)
    for i in range(len(data_list_587)):
        if (field_values[N] == field_list_587[i]):
            result = data_list_587[i] + energy_1_list[N]
            data_output_587.append(result)
# ----------------------------------------------------------------------------

# MF3
# ----------------------------------------------------------------------------
field_list_457 = []
data_list_457  = []
field_list_458 = []
data_list_458  = []
field_list_459 = []
data_list_459  = []
field_list_460 = []
data_list_460  = []
field_list_461 = []
data_list_461  = []
field_list_462 = []
data_list_462  = []
field_list_463 = []
data_list_463  = []
field_list_464 = []
data_list_464  = []
field_list_465 = []
data_list_465  = []
field_list_466 = []
data_list_466  = []
field_list_467 = []
data_list_467  = []
field_list_468 = []
data_list_468  = []
field_list_469 = []
data_list_469  = []

fin = open("data_mf3.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['457,']:
        field_list_457.append(float(columns[5:6][0]))
        data_list_457.append(float(columns[12:13][0]))
    if columns[1:2] == ['458,']:
        field_list_458.append(float(columns[5:6][0]))
        data_list_458.append(float(columns[12:13][0]))
    if columns[1:2] == ['459,']:
        field_list_459.append(float(columns[5:6][0]))
        data_list_459.append(float(columns[12:13][0]))
    if columns[1:2] == ['460,']:
        field_list_460.append(float(columns[5:6][0]))
        data_list_460.append(float(columns[12:13][0]))
    if columns[1:2] == ['461,']:
        field_list_461.append(float(columns[5:6][0]))
        data_list_461.append(float(columns[12:13][0]))
    if columns[1:2] == ['462,']:
        field_list_462.append(float(columns[5:6][0]))
        data_list_462.append(float(columns[12:13][0]))
    if columns[1:2] == ['463,']:
        field_list_463.append(float(columns[5:6][0]))
        data_list_463.append(float(columns[12:13][0]))  
    if columns[1:2] == ['464,']:
        field_list_464.append(float(columns[5:6][0]))
        data_list_464.append(float(columns[12:13][0]))  
    if columns[1:2] == ['465,']:
        field_list_465.append(float(columns[5:6][0]))
        data_list_465.append(float(columns[12:13][0]))  
    if columns[1:2] == ['466,']:
        field_list_466.append(float(columns[5:6][0]))
        data_list_466.append(float(columns[12:13][0]))  
    if columns[1:2] == ['467,']:
        field_list_467.append(float(columns[5:6][0]))
        data_list_467.append(float(columns[12:13][0]))  
    if columns[1:2] == ['468,']:
        field_list_468.append(float(columns[5:6][0]))
        data_list_468.append(float(columns[12:13][0]))
    if columns[1:2] == ['469,']:
        field_list_469.append(float(columns[5:6][0]))
        data_list_469.append(float(columns[12:13][0]))  
fin.close()

# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_457 = []
data_output_458 = []
data_output_459 = []
data_output_460 = []
data_output_461 = []
data_output_462 = []
data_output_463 = []
data_output_464 = []
data_output_465 = []
data_output_466 = []
data_output_467 = []
data_output_468 = []
data_output_469 = []
for N in range(len(field_values)):
    for i in range(len(data_list_457)):
        if (field_values[N] == field_list_457[i]):
            result = data_list_457[i] + energy_1_list[N]
            data_output_457.append(result)
    for i in range(len(data_list_458)):
        if (field_values[N] == field_list_458[i]):
            result = data_list_458[i] + energy_1_list[N]
            data_output_458.append(result)
    for i in range(len(data_list_459)):
        if (field_values[N] == field_list_459[i]):
            result = data_list_459[i] + energy_1_list[N]
            data_output_459.append(result)
    for i in range(len(data_list_460)):
        if (field_values[N] == field_list_460[i]):
            result = data_list_460[i] + energy_1_list[N]
            data_output_460.append(result)
    for i in range(len(data_list_461)):
        if (field_values[N] == field_list_461[i]):
            result = data_list_461[i] + energy_1_list[N]
            data_output_461.append(result)
    for i in range(len(data_list_462)):
        if (field_values[N] == field_list_462[i]):
            result = data_list_462[i] + energy_1_list[N]
            data_output_462.append(result)
    for i in range(len(data_list_463)):
        if (field_values[N] == field_list_463[i]):
            result = data_list_463[i] + energy_1_list[N]
            data_output_463.append(result)
    for i in range(len(data_list_464)):
        if (field_values[N] == field_list_464[i]):
            result = data_list_464[i] + energy_1_list[N]
            data_output_464.append(result)     
    for i in range(len(data_list_465)):
        if (field_values[N] == field_list_465[i]):
            result = data_list_465[i] + energy_1_list[N]
            data_output_465.append(result)
    for i in range(len(data_list_466)):
        if (field_values[N] == field_list_466[i]):
            result = data_list_466[i] + energy_1_list[N]
            data_output_466.append(result)
    for i in range(len(data_list_467)):
        if (field_values[N] == field_list_467[i]):
            result = data_list_467[i] + energy_1_list[N]
            data_output_467.append(result)
    for i in range(len(data_list_468)):
        if (field_values[N] == field_list_468[i]):
            result = data_list_468[i] + energy_1_list[N]
            data_output_468.append(result)   
    for i in range(len(data_list_469)):
        if (field_values[N] == field_list_469[i]):
            result = data_list_469[i] + energy_1_list[N]
            data_output_469.append(result)
# ----------------------------------------------------------------------------


# MF4 (L=2)
# ----------------------------------------------------------------------------
field_list_312_4 = []
data_list_312_4  = []
field_list_311_4 = []
data_list_311_4  = []
field_list_310_4 = []
data_list_310_4  = []
field_list_307_4 = []
data_list_307_4  = []
field_list_308_4 = []
data_list_308_4  = []
field_list_309_4 = []
data_list_309_4  = []
field_list_306_4 = []
data_list_306_4  = []

fin = open("data_mf4.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['306,']:
        field_list_306_4.append(float(columns[5:6][0]))
        data_list_306_4.append(float(columns[12:13][0]))   
    if columns[1:2] == ['307,']:
        field_list_307_4.append(float(columns[5:6][0]))
        data_list_307_4.append(float(columns[12:13][0]))
    if columns[1:2] == ['308,']:
        field_list_308_4.append(float(columns[5:6][0]))
        data_list_308_4.append(float(columns[12:13][0]))
    if columns[1:2] == ['309,']:
        field_list_309_4.append(float(columns[5:6][0]))
        data_list_309_4.append(float(columns[12:13][0]))
    if columns[1:2] == ['312,']:
        field_list_312_4.append(float(columns[5:6][0]))
        data_list_312_4.append(float(columns[12:13][0]))
    if columns[1:2] == ['311,']:
        field_list_311_4.append(float(columns[5:6][0]))
        data_list_311_4.append(float(columns[12:13][0]))
    if columns[1:2] == ['310,']:
        field_list_310_4.append(float(columns[5:6][0]))
        data_list_310_4.append(float(columns[12:13][0]))  
fin.close()

 
# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_306_4 = []
data_output_312_4 = []
data_output_311_4 = []
data_output_310_4 = []
data_output_307_4 = []
data_output_308_4 = []
data_output_309_4 = []
for N in range(len(field_values)):
    for i in range(len(data_list_306_4)):
        if (field_values[N] == field_list_306_4[i]):
            result = data_list_306_4[i] + energy_1_list[N]
            data_output_306_4.append(result)
    for i in range(len(data_list_312_4)):
        if (field_values[N] == field_list_312_4[i]):
            result = data_list_312_4[i] + energy_1_list[N]
            data_output_312_4.append(result)
    for i in range(len(data_list_311_4)):
        if (field_values[N] == field_list_311_4[i]):
            result = data_list_311_4[i] + energy_1_list[N]
            data_output_311_4.append(result)
    for i in range(len(data_list_310_4)):
        if (field_values[N] == field_list_310_4[i]):
            result = data_list_310_4[i] + energy_1_list[N]
            data_output_310_4.append(result)
    for i in range(len(data_list_307_4)):
        if (field_values[N] == field_list_307_4[i]):
            result = data_list_307_4[i] + energy_1_list[N]
            data_output_307_4.append(result)
    for i in range(len(data_list_308_4)):
        if (field_values[N] == field_list_308_4[i]):
            result = data_list_308_4[i] + energy_1_list[N]
            data_output_308_4.append(result)
    for i in range(len(data_list_309_4)):
        if (field_values[N] == field_list_309_4[i]):
            result = data_list_309_4[i] + energy_1_list[N]
            data_output_309_4.append(result)
# ----------------------------------------------------------------------------



# MF5
# ----------------------------------------------------------------------------
field_list_153 = []
data_list_153  = []
field_list_154 = []
data_list_154  = []
field_list_155 = []
data_list_155  = []


fin = open("data_mf5.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['153,']:
        field_list_153.append(float(columns[5:6][0]))
        data_list_153.append(float(columns[12:13][0]))
    if columns[1:2] == ['154,']:
        field_list_154.append(float(columns[5:6][0]))
        data_list_154.append(float(columns[12:13][0]))
    if columns[1:2] == ['155,']:
        field_list_155.append(float(columns[5:6][0]))
        data_list_155.append(float(columns[12:13][0]))
fin.close()


# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_153 = []
data_output_154 = []
data_output_155 = []
for N in range(len(field_values)):
    for i in range(len(data_list_153)):
        if (field_values[N] == field_list_153[i]):
            result = data_list_153[i] + energy_1_list[N]
            data_output_153.append(result)
    for i in range(len(data_list_154)):
        if (field_values[N] == field_list_154[i]):
            result = data_list_154[i] + energy_1_list[N]
            data_output_154.append(result)
    for i in range(len(data_list_155)):
        if (field_values[N] == field_list_155[i]):
            result = data_list_155[i] + energy_1_list[N]
            data_output_155.append(result)
# ----------------------------------------------------------------------------


# MF6
# ----------------------------------------------------------------------------
field_list_23 = []
data_list_23  = []

fin = open("data_mf6.txt", "r")
for line in fin:
    columns = line.split()
    if columns[1:2] == ['23,']:
        field_list_23.append(float(columns[5:6][0]))
        data_list_23.append(float(columns[12:13][0]))
fin.close()

   
# Adjust data for plotting on an absolute scale
# At each field, add the threshold energy 
data_output_23 = []
for N in range(len(field_values)):
    for i in range(len(data_list_23)):
        if (field_values[N] == field_list_23[i]):
            result = data_list_23[i] + energy_1_list[N]
            data_output_23.append(result)
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# data from file loaded into L2_plot.py for plotting. 
