<commit_before># -*- coding: utf-8 -*-
"""
Created on Wed Apr 01 11:16:10 2015

@author: TMM
"""

import matplotlib.pyplot as plt
import numpy as np
import plotRoutine

field = 15.0  # [arcsecs]
pixel_size = 10.0  # [arcsecs] 
grid_size = 1000.  # points on the grid
#field_scale = np.linspace(-field/2.0, field/2.0, grid)
#field_grid = np.ones((grid, grid))

"""
Specifying the spot size and fiber size. Fiber sized to 1/e (37% of peak) or 1/e2 (13.5% of peak).
These values are beam radius though, need diameter.
TODO: calculate 1/e diameter
"""
fwhm = 2.0  # fwhm of beam [arcsecs]
fiber_size = 2 * 0.8493218 * fwhm  # 1/e^2 DIAMETER [arcsecs]
#beam_diameter = 0.37  # 1/e DIAMETER TODO
sigma = fwhm / 2.3458  # [arcsecs]
mu = 0.0  # [arcsecs]

"""
Source and integration time to get number of photons.
Set up distributions to for binning.
"""
magnitude = 0.0  # TODO
n_photons = 10000.0

x = np.random.normal(0.0, sigma, n_photons)
y = np.random.normal(0.0, sigma, n_photons)

"""
Fine binning, take out fiber
"""
n_bins = 5000
assert np.mod(n_bins, 2) == 0  # Make fine binning even
bin_size = field / n_bins  # [arcsecs]
mask = plotRoutine.fiber_mask(fiber_size, n_bins, bin_size)
data, x1, y2 = plotRoutine.binner(x, y, n_bins, bin_size)

#plt.imshow(data)
plt.imshow(mask * data, interpolation='none')


#plotRoutine.plotter(x, y, pixel_size, grid_size, fiber_size)<commit_msg>Changing to masked array sturcture  for fiber, need to fix though<commit_after># -*- coding: utf-8 -*-
"""
Created on Wed Apr 01 11:16:10 2015

@author: TMM
"""

import matplotlib.pyplot as plt
import numpy as np
import plotRoutine
from scipy.stats import norm
from numpy import ma

field = 10.0  # [arcsecs]
pixel_size = 10.0  # [arcsecs] 
grid_size = 1000.  # points on the grid

"""
Specifying the spot size and fiber size. Fiber sized to 1/e (37% of peak) or 1/e2 (13.5% of peak).
These values are beam radius though, need diameter.
TODO: calculate 1/e diameter
"""
fwhm = 0.76  # fwhm of beam [arcsecs]
fiber_radius = 0.45  # 1/e radius [arcsecs]
sigma = fwhm / 2.3458  # [arcsecs]
mu = 0.0  # [arcsecs]

"""
Source and integration time to get number of photons.
Set up distributions to for binning.
"""
magnitude = 0.0  # TODO
n_photons = 10000.0

# Generate random photons
x = norm.rvs(loc=0.0, scale=sigma, size=n_photons)
y = norm.rvs(loc=0.0, scale=sigma, size=n_photons)

# Mask for fiber
x_masked = ma.masked_inside(x, -fiber_radius, fiber_radius).compressed()
y_masked = ma.masked_inside(y, -fiber_radius, fiber_radius).compressed()

# Adjust length for histogram
x = np.zeros(n_photons)
x[0:len(x_masked)] = x_masked
y=np.zeros(n_photons)
y[0:len(y_masked)] = y_masked


"""
Bin for detector
"""
n_bins = 500
bin_size = field / n_bins
xlims = [-(n_bins/2.0 * bin_size), (n_bins/2.0 * bin_size)]
ylims = [-(n_bins/2.0 * bin_size), (n_bins/2.0 * bin_size)]

# Create histogram and kill center value used for mathcing arrays
H, xedges, yedges = np.histogram2d(x, y, bins=n_bins, range=[xlims, ylims])
H[n_bins/2, n_bins/2] = 0 


#plt.imshow(data)
#plt.figure()
plt.imshow(H, interpolation='none')



'''
mask = plotRoutine.fiber_mask(fiber_radius, n_bins, bin_size)
data, x1, y2 = plotRoutine.binner(x, y, n_bins, bin_size)
'''
{'fraction_non_alphanumeric': 0.13771712158808933, 'fraction_numerical': 0.04869727047146402, 'mean_word_length': 4.16, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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}}
{'dir': 'git-commits-cleaned', 'id': '603894', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1288, 'n_words': 371}