Skip to content

Commit

Permalink
black pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
ambarb committed Oct 24, 2020
1 parent c168ffa commit 5cf2ec0
Show file tree
Hide file tree
Showing 14 changed files with 1,037 additions and 582 deletions.
32 changes: 16 additions & 16 deletions pyCHX/v2/_commonspeckle/DataGonio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import skbeam.core.roi as roi
import skbeam.core.correlation as corr
import skbeam.core.utils as utils
from pyCHX.v2._commonspeckle.chx_generic_functions import average_array_withNan #common
from pyCHX.v2._commonspeckle.chx_generic_functions import (
average_array_withNan,
) # common


def convert_Qmap(
Expand Down Expand Up @@ -837,21 +839,19 @@ def _generate_qxyz_maps(self):
x = np.arange(self.width) - self.x0
y = np.arange(self.height) - self.y0
X, Y = np.meshgrid(x, y)
R = np.sqrt(X**2 + Y**2)
R = np.sqrt(X ** 2 + Y ** 2)

#twotheta = np.arctan(self.r_map()*c) # radians
theta_f = np.arctan2( X*c, 1 ) # radians
#alpha_f_prime = np.arctan2( Y*c, 1 ) # radians
alpha_f = np.arctan2( Y*c*np.cos(theta_f), 1 ) # radians
# twotheta = np.arctan(self.r_map()*c) # radians
theta_f = np.arctan2(X * c, 1) # radians
# alpha_f_prime = np.arctan2( Y*c, 1 ) # radians
alpha_f = np.arctan2(Y * c * np.cos(theta_f), 1) # radians

self.qx_map_data1 = self.get_k() * np.sin(theta_f) * np.cos(alpha_f)
self.qy_map_data1 = self.get_k() * (
np.cos(theta_f) * np.cos(alpha_f) - 1
) # TODO: Check sign
self.qz_map_data1 = -1.0 * self.get_k() * np.sin(alpha_f)

self.qx_map_data1 = self.get_k()*np.sin(theta_f)*np.cos(alpha_f)
self.qy_map_data1 = self.get_k()*( np.cos(theta_f)*np.cos(alpha_f) - 1 ) # TODO: Check sign
self.qz_map_data1 = -1.0*self.get_k()*np.sin(alpha_f)

self.qr_map_data1 = np.sign(self.qx_map_data1)*np.sqrt(np.square(self.qx_map_data1) + np.square(self.qy_map_data1))





self.qr_map_data1 = np.sign(self.qx_map_data1) * np.sqrt(
np.square(self.qx_map_data1) + np.square(self.qy_map_data1)
)
15 changes: 10 additions & 5 deletions pyCHX/v2/_commonspeckle/SAXS.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
# import numpy as np
from lmfit import Model
from lmfit import minimize, Parameters, Parameter, report_fit, fit_report
#import matplotlib as mpl
#import matplotlib.pyplot as plt
#from matplotlib.colors import LogNorm
from pyCHX.v2._commonspeckle.chx_libs import * #common
from pyCHX.v2._commonspeckle.chx_generic_functions import show_img, plot1D, find_index #common

# import matplotlib as mpl
# import matplotlib.pyplot as plt
# from matplotlib.colors import LogNorm
from pyCHX.v2._commonspeckle.chx_libs import * # common
from pyCHX.v2._commonspeckle.chx_generic_functions import (
show_img,
plot1D,
find_index,
) # common
from scipy.special import gamma, gammaln
from scipy.optimize import leastsq, curve_fit, least_squares

Expand Down
21 changes: 14 additions & 7 deletions pyCHX/v2/_commonspeckle/Stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import numpy as np
from scipy.signal import savgol_filter as sf
import matplotlib.pyplot as plt
from pyCHX.v2._commonspeckle.chx_generic_functions import show_img, plot1D #common
from pyCHX.v2._commonspeckle.DataGonio import convert_Qmap #common #TODO how much overlap with skbeam.core.recip
from pyCHX.v2._commonspeckle.chx_generic_functions import show_img, plot1D # common
from pyCHX.v2._commonspeckle.DataGonio import (
convert_Qmap,
) # common #TODO how much overlap with skbeam.core.recip


def get_base_all_filenames(inDir, base_filename_cut_length=-7):
Expand Down Expand Up @@ -253,12 +255,17 @@ def stitch_WAXS_in_Qspace(
return Intensity_map, qxs, qzs


def plot_qmap_in_folder( inDir ): #TODO is this made for SMI as per docstring?
'''YG. Sep 27@SMI
def plot_qmap_in_folder(inDir): # TODO is this made for SMI as per docstring?
"""YG. Sep 27@SMI
Plot Qmap data from inDir, which contains qmap data and extent data
'''
from pyCHX.v2._commonspeckle.chx_generic_functions import show_img #common #TODO why importing in a function?
from pyCHX.v2._commonspeckle.chx_libs import cmap_vge_hdr, plt #common #TODO why importing in a function?
"""
from pyCHX.v2._commonspeckle.chx_generic_functions import (
show_img,
) # common #TODO why importing in a function?
from pyCHX.v2._commonspeckle.chx_libs import (
cmap_vge_hdr,
plt,
) # common #TODO why importing in a function?
import pickle as cpl

fp = get_base_all_filenames(inDir, base_filename_cut_length=-10)
Expand Down
60 changes: 39 additions & 21 deletions pyCHX/v2/_commonspeckle/Two_Time_Correlation_Function.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,45 @@
import itertools
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from pyCHX.v2._commonspeckle.chx_libs import ( colors as colors_array, markers as markers_array, markers_copy, lstyles, Figure, RUN_GUI) #common
#from pyCHX.chx_libs import colors_ as mcolors, markers_ as markers
from pyCHX.v2._commonspeckle.chx_libs import mcolors, markers, multi_tau_lags, colors #common
#from modest_image import ModestImage, imshow #common

def delays( num_lev=3, num_buf=4, time=1 ):
''' DOCUMENT delays(time=)
return array of delays.
KEYWORD: time: scale delays by time ( should be time between frames)
'''
if num_buf%2!=0:print ("nobuf must be even!!!" )
dly=np.zeros( (num_lev+1)*int(num_buf/2) +1 )
dict_dly ={}
for i in range( 1,num_lev+1):
if i==1:imin= 1
else:imin= int(num_buf/2)+1
ptr=(i-1)*int(num_buf/2)+ np.arange(imin,num_buf+1)
dly[ptr]= np.arange( imin, num_buf+1) *2**(i-1)
dict_dly[i] = dly[ptr-1]
dly*=time
#print (i, ptr, imin)
from pyCHX.v2._commonspeckle.chx_libs import (
colors as colors_array,
markers as markers_array,
markers_copy,
lstyles,
Figure,
RUN_GUI,
) # common

# from pyCHX.chx_libs import colors_ as mcolors, markers_ as markers
from pyCHX.v2._commonspeckle.chx_libs import (
mcolors,
markers,
multi_tau_lags,
colors,
) # common

# from modest_image import ModestImage, imshow #common


def delays(num_lev=3, num_buf=4, time=1):
"""DOCUMENT delays(time=)
return array of delays.
KEYWORD: time: scale delays by time ( should be time between frames)
"""
if num_buf % 2 != 0:
print("nobuf must be even!!!")
dly = np.zeros((num_lev + 1) * int(num_buf / 2) + 1)
dict_dly = {}
for i in range(1, num_lev + 1):
if i == 1:
imin = 1
else:
imin = int(num_buf / 2) + 1
ptr = (i - 1) * int(num_buf / 2) + np.arange(imin, num_buf + 1)
dly[ptr] = np.arange(imin, num_buf + 1) * 2 ** (i - 1)
dict_dly[i] = dly[ptr - 1]
dly *= time
# print (i, ptr, imin)
return dly, dict_dly


Expand Down
Loading

0 comments on commit 5cf2ec0

Please sign in to comment.