Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,14 +66,21 @@ def norm(df, i, j, u, v, m, p, mix_norm):
|
|
66 |
v_col= df2.columns[((df2.columns.get_loc(int(f'{v}'))+1))]
|
67 |
m_col= df2.columns[((df2.columns.get_loc(int(f'{m}'))+1))]
|
68 |
p_col= df2.columns[((df2.columns.get_loc(int(f'{p}'))+1))]
|
69 |
-
|
70 |
-
|
71 |
-
df2[m_col]=0
|
72 |
-
else:
|
73 |
df2[i]=0
|
74 |
-
df2[i_col]=0
|
75 |
df2[j]=0
|
76 |
-
df2[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
for ii in range(1,df2.shape[1],2):
|
79 |
k= df2.columns[ii]
|
@@ -113,9 +120,9 @@ def mix_norm_click(bool):
|
|
113 |
|
114 |
def hide_intro(intro):
|
115 |
if intro==1:
|
116 |
-
return gr.update(value=0), gr.update(value="
|
117 |
else:
|
118 |
-
return gr.update(value=1), gr.update(value="Hide
|
119 |
|
120 |
def search_sample_names(df):
|
121 |
names=df.iloc[:, 0].tolist()
|
@@ -135,17 +142,19 @@ def search_sample_names(df):
|
|
135 |
|
136 |
|
137 |
with gr.Blocks() as demo:
|
138 |
-
gr.Markdown("""
|
139 |
-
# Epsilon Value Transformation Script
|
140 |
-
Created by Dan Razionale :: Last updated May 24<sup>th</sup>, 2023""")
|
141 |
format= '<a href="{link}">{text}</a>'
|
142 |
text_with_link=format.format
|
|
|
|
|
|
|
|
|
143 |
with gr.Row():
|
144 |
with gr.Column(scale=1):
|
145 |
a1=gr.Markdown(f"""
|
146 |
# Introduction:
|
147 |
-
This script automates the
|
148 |
-
|
|
|
149 |
with gr.Column(scale=1):
|
150 |
a2=gr.Markdown("""# Calculations:""")
|
151 |
with gr.Row():
|
@@ -156,14 +165,14 @@ with gr.Blocks() as demo:
|
|
156 |
with gr.Column(scale=1):
|
157 |
a3=gr.Markdown("""
|
158 |
# Formatting Guidelines:
|
159 |
-
The functionality of this application hinges upon proper formatting of
|
160 |
with gr.Column(scale=1):
|
161 |
-
a4=gr.Markdown("k denotes the identity of the isotope
|
162 |
-
with gr.Row():
|
163 |
-
|
164 |
with gr.Row():
|
165 |
-
intro=gr.Number(value=
|
166 |
-
hide.click(fn=hide_intro, inputs=[intro], outputs=[intro,hide,
|
167 |
|
168 |
with gr.Row():
|
169 |
with gr.Column(scale=1, min_width=100):
|
@@ -173,16 +182,16 @@ with gr.Blocks() as demo:
|
|
173 |
with gr.Row():
|
174 |
upload_button = gr.UploadButton("Import Data", file_types=[".xlsx"], file_count=1)
|
175 |
with gr.Row():
|
176 |
-
norm_button=gr.Button("Transform and Plot
|
177 |
|
178 |
with gr.Column(scale=1, min_width=100):
|
179 |
-
i= gr.Number(label="Current Isotope Pair for Internal Normalization", info="e.g. for 98Mo/96Mo", value=98, precision=0)
|
180 |
j= gr.Number(label="", value=96, precision=0)
|
181 |
-
m=gr.Number(visible=False, label= "Current Index Isotope", value=96, info= "e.g. for
|
182 |
with gr.Column(scale=1, min_width=100):
|
183 |
-
u=gr.Number(label="Desired Isotope Pair for Internal Normalization", info="e.g. for 97Mo/95Mo", value=97, precision=0)
|
184 |
v=gr.Number(label="", precision=0, value=95)
|
185 |
-
p=gr.Number(visible=False, label= "Desired Index Isotope", value=95, info= "e.g. for
|
186 |
mix_norm.change(fn=mix_norm_click, inputs=[mix_norm], outputs=[m, p])
|
187 |
|
188 |
with gr.Row():
|
@@ -207,8 +216,8 @@ with gr.Blocks() as demo:
|
|
207 |
with gr.Column(scale=1.1):
|
208 |
upload_button.upload(upload_file, upload_button, outputs=[ file_output,og_Data]).success(fn=search_sample_names, inputs=[og_Data], outputs=[og_Data])
|
209 |
|
210 |
-
norm_button.click(fn=search_sample_names, inputs=[og_Data],outputs=[og_Data]).success(
|
211 |
fn=norm,inputs=[og_Data, i, j, u, v, m, p, mix_norm],outputs=[norm_Data, xx], scroll_to_output=True).success(fn=plot, inputs=[og_Data, i, j, Element, m, mix_norm], outputs=og_Plot, scroll_to_output=True).success(
|
212 |
fn=plot, inputs=[norm_Data, u, v, Element, p, mix_norm], outputs=norm_Plot).success(fn=write_xl, inputs=[norm_Data, u, v, Element, mix_norm,p], outputs=[xx])
|
213 |
|
214 |
-
demo.launch(debug=True)
|
|
|
66 |
v_col= df2.columns[((df2.columns.get_loc(int(f'{v}'))+1))]
|
67 |
m_col= df2.columns[((df2.columns.get_loc(int(f'{m}'))+1))]
|
68 |
p_col= df2.columns[((df2.columns.get_loc(int(f'{p}'))+1))]
|
69 |
+
|
70 |
+
if mix_norm==False:
|
|
|
|
|
71 |
df2[i]=0
|
|
|
72 |
df2[j]=0
|
73 |
+
for err in df2[i_col]:
|
74 |
+
if err == "":
|
75 |
+
err=0
|
76 |
+
for err in df2[j_col]:
|
77 |
+
if err =="":
|
78 |
+
err=0
|
79 |
+
elif mix_norm==True:
|
80 |
+
df2[m]=0
|
81 |
+
for err in df2[m_col]:
|
82 |
+
if err=="":
|
83 |
+
err=0
|
84 |
|
85 |
for ii in range(1,df2.shape[1],2):
|
86 |
k= df2.columns[ii]
|
|
|
120 |
|
121 |
def hide_intro(intro):
|
122 |
if intro==1:
|
123 |
+
return gr.update(value=0), gr.update(value="Example Input Formatting"),gr.update(visible=False)
|
124 |
else:
|
125 |
+
return gr.update(value=1), gr.update(value="Hide Formatting"),gr.update(visible=True)
|
126 |
|
127 |
def search_sample_names(df):
|
128 |
names=df.iloc[:, 0].tolist()
|
|
|
142 |
|
143 |
|
144 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
145 |
format= '<a href="{link}">{text}</a>'
|
146 |
text_with_link=format.format
|
147 |
+
gr.Markdown(f"""
|
148 |
+
# Epsilon-value Transformation
|
149 |
+
{text_with_link(link='http://mailto:dan_razionale@brown.edu?subject=Epsilon-value%20Transformation', text='Dan Razionale')} and Gerrit Budde; Department of Earth, Environmental and Planetary Sciences, Brown University, Providence, RI 02912, USA.""")
|
150 |
+
gr.Markdown(f"""Last updated May 26<sup>th</sup>, 2023 :: {text_with_link(link='https://huggingface.co/spaces/dpraz/Epsilon_Transformation', text='Link to Repository')}""")
|
151 |
with gr.Row():
|
152 |
with gr.Column(scale=1):
|
153 |
a1=gr.Markdown(f"""
|
154 |
# Introduction:
|
155 |
+
This script automates the transformation of internally-normalized isotope data, as originally described by {text_with_link(link='http://dx.doi.org/10.1086/182628', text='McCulloch & Wasserburg (1978).')} It allows the re-calculation of ε-values for any element using alternative isotope pairs for the internal normalization. In using this script, you will generate an interactive plot and table with the re-normalized data, both of which are downloadable. Additionally, errors on your original data will propagate to the new data, if included. Note: if errors are not provided for isotopes used in the original internal normalization (m, i, or j), they are assumed to be zero. If any of these isotopes are then used for the new normalization (as p, u, or v), the propagated error will underestimate the total error. Otherwise, if error is omitted for isotope k, p, u or v, no propagated error will be displayed.""")
|
156 |
+
with gr.Row():
|
157 |
+
hide=gr.Button(value="Example Input Formatting").style(size="sm", full_width=False)############
|
158 |
with gr.Column(scale=1):
|
159 |
a2=gr.Markdown("""# Calculations:""")
|
160 |
with gr.Row():
|
|
|
165 |
with gr.Column(scale=1):
|
166 |
a3=gr.Markdown("""
|
167 |
# Formatting Guidelines:
|
168 |
+
To begin, assemble an excel document containing the data you wish to transform and save it in an easily accessible location. The functionality of this application hinges upon proper formatting of the input data – please adhere closely to the format defined in the annotated image. As an example, we provide a molybdenum dataset that is internally normalized to <sup>98</sup>Mo/<sup>96</sup>Mo, to be transformed to a <sup>97</sup>Mo/<sup>95</sup>Mo normalization.""")
|
169 |
with gr.Column(scale=1):
|
170 |
+
a4=gr.Markdown("k denotes the identity of the isotope of interest; u/v and i/j represent the new and old isotope pair used for internal normalization, respectively; p and m are the new and old index isotopes, respectively, which are the denominators in the isotope ratios. Usually, p=v and m=j, although ‘mixed normalizations’ are permitted by activating the homonymous checkbox, which allows you to manually set these indices. Where these variables are not preceded by an epsilon sign, they simply refer to the mass number of the respective isotopes; where they are preceded by a delta, they refer to the associated absolute error. ")
|
171 |
+
with gr.Row():
|
172 |
+
format_img=gr.Image("Formatting.png", show_label=False, visible=False).style(height=400, width=750)
|
173 |
with gr.Row():
|
174 |
+
intro=gr.Number(value=0, visible=False)
|
175 |
+
hide.click(fn=hide_intro, inputs=[intro], outputs=[intro,hide,format_img])
|
176 |
|
177 |
with gr.Row():
|
178 |
with gr.Column(scale=1, min_width=100):
|
|
|
182 |
with gr.Row():
|
183 |
upload_button = gr.UploadButton("Import Data", file_types=[".xlsx"], file_count=1)
|
184 |
with gr.Row():
|
185 |
+
norm_button=gr.Button("Transform and Plot")
|
186 |
|
187 |
with gr.Column(scale=1, min_width=100):
|
188 |
+
i= gr.Number(label="Current Isotope Pair for Internal Normalization [i/j]", info="e.g. for 98Mo/96Mo", value=98, precision=0)
|
189 |
j= gr.Number(label="", value=96, precision=0)
|
190 |
+
m=gr.Number(visible=False, label= "Current Index Isotope [m]", value=96, info= "e.g. for kMo/96Mo", precision=0)
|
191 |
with gr.Column(scale=1, min_width=100):
|
192 |
+
u=gr.Number(label="Desired Isotope Pair for Internal Normalization [u/v]", info="e.g. for 97Mo/95Mo", value=97, precision=0)
|
193 |
v=gr.Number(label="", precision=0, value=95)
|
194 |
+
p=gr.Number(visible=False, label= "Desired Index Isotope [p]", value=95, info= "e.g. for kMo/95Mo", precision=0)
|
195 |
mix_norm.change(fn=mix_norm_click, inputs=[mix_norm], outputs=[m, p])
|
196 |
|
197 |
with gr.Row():
|
|
|
216 |
with gr.Column(scale=1.1):
|
217 |
upload_button.upload(upload_file, upload_button, outputs=[ file_output,og_Data]).success(fn=search_sample_names, inputs=[og_Data], outputs=[og_Data])
|
218 |
|
219 |
+
norm_button.click(fn=search_sample_names, inputs=[og_Data],outputs=[og_Data]).success(
|
220 |
fn=norm,inputs=[og_Data, i, j, u, v, m, p, mix_norm],outputs=[norm_Data, xx], scroll_to_output=True).success(fn=plot, inputs=[og_Data, i, j, Element, m, mix_norm], outputs=og_Plot, scroll_to_output=True).success(
|
221 |
fn=plot, inputs=[norm_Data, u, v, Element, p, mix_norm], outputs=norm_Plot).success(fn=write_xl, inputs=[norm_Data, u, v, Element, mix_norm,p], outputs=[xx])
|
222 |
|
223 |
+
demo.queue(concurrency_count=5).launch(debug=True)
|