In [2]:
import os
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
import numpy

import amplitude



In [1]:
def plot_r(traces, log_type='log', notes=None):
    x_layout = dict(title=u"Q [1/\u212b]", zeroline=False, exponentformat="power",
                    showexponent="all", showgrid=False, type='log',
                    titlefont=dict(size=26),
                    tickfont=dict(size=14), linewidth=3,
                    showline=True, mirror="all", ticks="outside")

    y_layout = dict(title="Intensity [a.u.]", zeroline=False, exponentformat="power",
                    showexponent="all", showgrid=False, type=log_type,
                    titlefont=dict(size=26),
                    tickfont=dict(size=14), linewidth=3,
                    showline=True, mirror="all", ticks="outside")
    annotations = []
    if notes is not None:
        annotations = [dict(text=notes, showarrow=False, x=-2.5, y=-3, font=dict(size=22))]
    layout = go.Layout(
        showlegend=True,
        legend=dict(x=0.01, y=0.1, font=dict(size=11)),
        autosize=True,
        width=700,
        height=500,
        margin=dict(t=40, b=100, l=140, r=40),
        hovermode='closest',
        bargap=0,
        xaxis=x_layout,
        yaxis=y_layout,
        annotations=annotations
    )

    fig = go.Figure(data=traces, layout=layout)
    py.iplot(fig, show_link=False)

In [20]:
import pandas

traces = []

for item in [
         ["/Users/m2d/Dropbox (ORNL)/experiments/Katie/LiPAA/new_LiPAA_Ebeam_all_RQz.txt", 'old'],

         ["/Users/m2d/Dropbox (ORNL)/experiments/Katie/LiPAA_NR/Air/LiPAA_air_03deg_RQz.txt", '1'],

         ["/Users/m2d/Dropbox (ORNL)/experiments/Katie/LiPAA_NR/Air/LiPAA_air_07deg_RQz.txt", '2'],


            ]:
    data = numpy.loadtxt(item[0], unpack=False, skiprows=1)    
    data=data.transpose()
    
    q = data[0]
    y = data[1]
    dy = data[2]

    # mode="markers"
    err_y = dict(type='data', array=dy, visible=True)
    traces.append(go.Scatter(name=item[1], x=q, y=y, error_y=err_y,
                             mode="line", marker=dict(size=2)))#, color="black")))

plot_r(traces, log_type='log')



In [36]:
#import amplitude_nomag as amplitude
import amplitude

import imp
imp.reload(amplitude)


layers = []
layers.append(amplitude.Layer(0, 0, 0))    # Air
#layers.append(amplitude.Layer(500, 3e-6, 0))

layers.append(amplitude.Layer(100, 6e-6, 0))

layers.append(amplitude.Layer(0, 2.07e-6, 0)) # Si substrate


a = amplitude.Amplitude(layers=layers, n_alpha_i=200, alpha_i_max=10)
a()
i_wl = 1
_wl = a.wavelength(i_wl)
q, y = a.reflectivity(i_wl)
dy = 0.05*numpy.asarray(y)

with open('/Users/m2d/Desktop/one_layer.txt', 'w') as fd:
    for i in range(len(q)):
        fd.write("%s %s %s 0.0\n" % (q[i], y[i], dy[i]))



traces = []
# mode="markers"
#err_y = dict(type='data', array=dy, visible=True)
traces.append(go.Scatter(name='wl=%s' % _wl, x=q, y=y, #error_y=err_y,
                         mode="line", marker=dict(size=2)))#, color="black")))

plot_r(traces, log_type='log')


Wavelength = 5.0