_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q262600
diffusion
validation
def diffusion(diffusion_constant=0.2, exposure_time=0.05, samples=200): """ See `diffusion_correlated` for information related to units, etc """ radius = 5 psfsize = np.array([2.0, 1.0, 3.0]) # create a base image of one particle s0 = init.create_single_particle_state(imsize=4*radius, ...
python
{ "resource": "" }
q262601
feature_guess
validation
def feature_guess(st, rad, invert='guess', minmass=None, use_tp=False, trim_edge=False, **kwargs): """ Makes a guess at particle positions using heuristic centroid methods. Parameters ---------- st : :class:`peri.states.State` The state to check adding particles to. ra...
python
{ "resource": "" }
q262602
_feature_guess
validation
def _feature_guess(im, rad, minmass=None, use_tp=False, trim_edge=False): """Workhorse of feature_guess""" if minmass is None: # we use 1% of the feature size mass as a cutoff; # it's easier to remove than to add minmass = rad**3 * 4/3.*np.pi * 0.01 # 0.03 is a magic number; work...
python
{ "resource": "" }
q262603
check_add_particles
validation
def check_add_particles(st, guess, rad='calc', do_opt=True, im_change_frac=0.2, min_derr='3sig', **kwargs): """ Checks whether to add particles at a given position by seeing if adding the particle improves the fit of the state. Parameters ---------- st : :class:`peri.sta...
python
{ "resource": "" }
q262604
should_particle_exist
validation
def should_particle_exist(absent_err, present_err, absent_d, present_d, im_change_frac=0.2, min_derr=0.1): """ Checks whether or not adding a particle should be present. Parameters ---------- absent_err : Float The state error without the particle. present_err ...
python
{ "resource": "" }
q262605
add_missing_particles
validation
def add_missing_particles(st, rad='calc', tries=50, **kwargs): """ Attempts to add missing particles to the state. Operates by: (1) featuring the difference image using feature_guess, (2) attempting to add the featured positions using check_add_particles. Parameters ---------- st : :cl...
python
{ "resource": "" }
q262606
add_subtract
validation
def add_subtract(st, max_iter=7, max_npart='calc', max_mem=2e8, always_check_remove=False, **kwargs): """ Automatically adds and subtracts missing & extra particles. Operates by removing bad particles then adding missing particles on repeat, until either no particles are added/removed ...
python
{ "resource": "" }
q262607
add_subtract_misfeatured_tile
validation
def add_subtract_misfeatured_tile( st, tile, rad='calc', max_iter=3, invert='guess', max_allowed_remove=20, minmass=None, use_tp=False, **kwargs): """ Automatically adds and subtracts missing & extra particles in a region of poor fit. Parameters ---------- st: :class:`peri.state...
python
{ "resource": "" }
q262608
add_subtract_locally
validation
def add_subtract_locally(st, region_depth=3, filter_size=5, sigma_cutoff=8, **kwargs): """ Automatically adds and subtracts missing particles based on local regions of poor fit. Calls identify_misfeatured_regions to identify regions, then add_subtract_misfeatured_tile on th...
python
{ "resource": "" }
q262609
guess_invert
validation
def guess_invert(st): """Guesses whether particles are bright on a dark bkg or vice-versa Works by checking whether the intensity at the particle centers is brighter or darker than the average intensity of the image, by comparing the median intensities of each. Parameters ---------- st : :...
python
{ "resource": "" }
q262610
load_wisdom
validation
def load_wisdom(wisdomfile): """ Prime FFTW with knowledge of which FFTs are best on this machine by loading 'wisdom' from the file ``wisdomfile`` """ if wisdomfile is None: return try: pyfftw.import_wisdom(pickle.load(open(wisdomfile, 'rb'))) except (IOError, TypeError) as ...
python
{ "resource": "" }
q262611
save_wisdom
validation
def save_wisdom(wisdomfile): """ Save the acquired 'wisdom' generated by FFTW to file so that future initializations of FFTW will be faster. """ if wisdomfile is None: return if wisdomfile: pickle.dump( pyfftw.export_wisdom(), open(wisdomfile, 'wb'), prot...
python
{ "resource": "" }
q262612
tile_overlap
validation
def tile_overlap(inner, outer, norm=False): """ How much of inner is in outer by volume """ div = 1.0/inner.volume if norm else 1.0 return div*(inner.volume - util.Tile.intersection(inner, outer).volume)
python
{ "resource": "" }
q262613
separate_particles_into_groups
validation
def separate_particles_into_groups(s, region_size=40, bounds=None): """ Given a state, returns a list of groups of particles. Each group of particles are located near each other in the image. Every particle located in the desired region is contained in exactly 1 group. Parameters: ----------- ...
python
{ "resource": "" }
q262614
create_comparison_state
validation
def create_comparison_state(image, position, radius=5.0, snr=20, method='constrained-cubic', extrapad=2, zscale=1.0): """ Take a platonic image and position and create a state which we can use to sample the error for peri. Also return the blurred platonic image so we can vary the noise on it lat...
python
{ "resource": "" }
q262615
perfect_platonic_per_pixel
validation
def perfect_platonic_per_pixel(N, R, scale=11, pos=None, zscale=1.0, returnpix=None): """ Create a perfect platonic sphere of a given radius R by supersampling by a factor scale on a grid of size N. Scale must be odd. We are able to perfectly position these particles up to 1/scale. Therefore, let'...
python
{ "resource": "" }
q262616
translate_fourier
validation
def translate_fourier(image, dx): """ Translate an image in fourier-space with plane waves """ N = image.shape[0] f = 2*np.pi*np.fft.fftfreq(N) kx,ky,kz = np.meshgrid(*(f,)*3, indexing='ij') kv = np.array([kx,ky,kz]).T q = np.fft.fftn(image)*np.exp(-1.j*(kv*dx).sum(axis=-1)).T return np.re...
python
{ "resource": "" }
q262617
users
validation
def users(): """Load default users and groups.""" from invenio_groups.models import Group, Membership, \ PrivacyPolicy, SubscriptionPolicy admin = accounts.datastore.create_user( email='admin@inveniosoftware.org', password=encrypt_password('123456'), active=True, ) r...
python
{ "resource": "" }
q262618
BarnesInterpolation1D._weight
validation
def _weight(self, rsq, sigma=None): """weighting function for Barnes""" sigma = sigma or self.filter_size if not self.clip: o = np.exp(-rsq / (2*sigma**2)) else: o = np.zeros(rsq.shape, dtype='float') m = (rsq < self.clipsize**2) o[m] = np...
python
{ "resource": "" }
q262619
BarnesInterpolation1D._eval_firstorder
validation
def _eval_firstorder(self, rvecs, data, sigma): """The first-order Barnes approximation""" if not self.blocksize: dist_between_points = self._distance_matrix(rvecs, self.x) gaussian_weights = self._weight(dist_between_points, sigma=sigma) return gaussian_weights.dot(d...
python
{ "resource": "" }
q262620
BarnesInterpolation1D._newcall
validation
def _newcall(self, rvecs): """Correct, normalized version of Barnes""" # 1. Initial guess for output: sigma = 1*self.filter_size out = self._eval_firstorder(rvecs, self.d, sigma) # 2. There are differences between 0th order at the points and # the passed data, so we it...
python
{ "resource": "" }
q262621
BarnesInterpolationND._distance_matrix
validation
def _distance_matrix(self, a, b): """Pairwise distance between each point in `a` and each point in `b`""" def sq(x): return (x * x) # matrix = np.sum(map(lambda a,b: sq(a[:,None] - b[None,:]), a.T, # b.T), axis=0) # A faster version than above: matrix = sq(a[:, 0][:, No...
python
{ "resource": "" }
q262622
ChebyshevInterpolation1D._c2x
validation
def _c2x(self, c): """ Convert cheb coordinates to windowdow coordinates """ return 0.5 * (self.window[0] + self.window[1] + c * (self.window[1] - self.window[0]))
python
{ "resource": "" }
q262623
ChebyshevInterpolation1D.tk
validation
def tk(self, k, x): """ Evaluates an individual Chebyshev polynomial `k` in coordinate space with proper transformation given the window """ weights = np.diag(np.ones(k+1))[k] return np.polynomial.chebyshev.chebval(self._x2c(x), weights)
python
{ "resource": "" }
q262624
resolve_admin_type
validation
def resolve_admin_type(admin): """Determine admin type.""" if admin is current_user or isinstance(admin, UserMixin): return 'User' else: return admin.__class__.__name__
python
{ "resource": "" }
q262625
SubscriptionPolicy.validate
validation
def validate(cls, policy): """Validate subscription policy value.""" return policy in [cls.OPEN, cls.APPROVAL, cls.CLOSED]
python
{ "resource": "" }
q262626
PrivacyPolicy.validate
validation
def validate(cls, policy): """Validate privacy policy value.""" return policy in [cls.PUBLIC, cls.MEMBERS, cls.ADMINS]
python
{ "resource": "" }
q262627
MembershipState.validate
validation
def validate(cls, state): """Validate state value.""" return state in [cls.ACTIVE, cls.PENDING_ADMIN, cls.PENDING_USER]
python
{ "resource": "" }
q262628
Group.delete
validation
def delete(self): """Delete a group and all associated memberships.""" with db.session.begin_nested(): Membership.query_by_group(self).delete() GroupAdmin.query_by_group(self).delete() GroupAdmin.query_by_admin(self).delete() db.session.delete(self)
python
{ "resource": "" }
q262629
Group.update
validation
def update(self, name=None, description=None, privacy_policy=None, subscription_policy=None, is_managed=None): """Update group. :param name: Name of group. :param description: Description of group. :param privacy_policy: PrivacyPolicy :param subscription_policy: S...
python
{ "resource": "" }
q262630
Group.get_by_name
validation
def get_by_name(cls, name): """Query group by a group name. :param name: Name of a group to search for. :returns: Group object or None. """ try: return cls.query.filter_by(name=name).one() except NoResultFound: return None
python
{ "resource": "" }
q262631
Group.query_by_names
validation
def query_by_names(cls, names): """Query group by a list of group names. :param list names: List of the group names. :returns: Query object. """ assert isinstance(names, list) return cls.query.filter(cls.name.in_(names))
python
{ "resource": "" }
q262632
Group.query_by_user
validation
def query_by_user(cls, user, with_pending=False, eager=False): """Query group by user. :param user: User object. :param bool with_pending: Whether to include pending users. :param bool eager: Eagerly fetch group members. :returns: Query object. """ q1 = Group.que...
python
{ "resource": "" }
q262633
Group.search
validation
def search(cls, query, q): """Modify query as so include only specific group names. :param query: Query object. :param str q: Search string. :returs: Query object. """ return query.filter(Group.name.like('%{0}%'.format(q)))
python
{ "resource": "" }
q262634
Group.add_member
validation
def add_member(self, user, state=MembershipState.ACTIVE): """Invite a user to a group. :param user: User to be added as a group member. :param state: MembershipState. Default: MembershipState.ACTIVE. :returns: Membership object or None. """ return Membership.create(self,...
python
{ "resource": "" }
q262635
Group.invite_by_emails
validation
def invite_by_emails(self, emails): """Invite users to a group by emails. :param list emails: Emails of users that shall be invited. :returns list: Newly created Memberships or Nones. """ assert emails is None or isinstance(emails, list) results = [] for email ...
python
{ "resource": "" }
q262636
Group.is_member
validation
def is_member(self, user, with_pending=False): """Verify if given user is a group member. :param user: User to be checked. :param bool with_pending: Whether to include pending users or not. :returns: True or False. """ m = Membership.get(self, user) if m is not N...
python
{ "resource": "" }
q262637
Group.can_see_members
validation
def can_see_members(self, user): """Determine if given user can see other group members. :param user: User to be checked. :returns: True or False. """ if self.privacy_policy == PrivacyPolicy.PUBLIC: return True elif self.privacy_policy == PrivacyPolicy.MEMBER...
python
{ "resource": "" }
q262638
Group.can_invite_others
validation
def can_invite_others(self, user): """Determine if user can invite people to a group. Be aware that this check is independent from the people (users) which are going to be invited. The checked user is the one who invites someone, NOT who is going to be invited. :param user: Use...
python
{ "resource": "" }
q262639
Membership.get
validation
def get(cls, group, user): """Get membership for given user and group. :param group: Group object. :param user: User object. :returns: Membership or None. """ try: m = cls.query.filter_by(user_id=user.get_id(), group=group).one() return m ...
python
{ "resource": "" }
q262640
Membership._filter
validation
def _filter(cls, query, state=MembershipState.ACTIVE, eager=None): """Filter a query result.""" query = query.filter_by(state=state) eager = eager or [] for field in eager: query = query.options(joinedload(field)) return query
python
{ "resource": "" }
q262641
Membership.query_by_user
validation
def query_by_user(cls, user, **kwargs): """Get a user's memberships.""" return cls._filter( cls.query.filter_by(user_id=user.get_id()), **kwargs )
python
{ "resource": "" }
q262642
Membership.query_invitations
validation
def query_invitations(cls, user, eager=False): """Get all invitations for given user.""" if eager: eager = [Membership.group] return cls.query_by_user(user, state=MembershipState.PENDING_USER, eager=eager)
python
{ "resource": "" }
q262643
Membership.query_requests
validation
def query_requests(cls, admin, eager=False): """Get all pending group requests.""" # Get direct pending request if hasattr(admin, 'is_superadmin') and admin.is_superadmin: q1 = GroupAdmin.query.with_entities( GroupAdmin.group_id) else: q1 = GroupAd...
python
{ "resource": "" }
q262644
Membership.query_by_group
validation
def query_by_group(cls, group_or_id, with_invitations=False, **kwargs): """Get a group's members.""" if isinstance(group_or_id, Group): id_group = group_or_id.id else: id_group = group_or_id if not with_invitations: return cls._filter( ...
python
{ "resource": "" }
q262645
Membership.search
validation
def search(cls, query, q): """Modify query as so include only specific members. :param query: Query object. :param str q: Search string. :returs: Query object. """ query = query.join(User).filter( User.email.like('%{0}%'.format(q)), ) retu...
python
{ "resource": "" }
q262646
Membership.order
validation
def order(cls, query, field, s): """Modify query as so to order the results. :param query: Query object. :param str s: Orderinig: ``asc`` or ``desc``. :returs: Query object. """ if s == 'asc': query = query.order_by(asc(field)) elif s == 'desc': ...
python
{ "resource": "" }
q262647
Membership.create
validation
def create(cls, group, user, state=MembershipState.ACTIVE): """Create a new membership.""" with db.session.begin_nested(): membership = cls( user_id=user.get_id(), id_group=group.id, state=state, ) db.session.add(members...
python
{ "resource": "" }
q262648
Membership.delete
validation
def delete(cls, group, user): """Delete membership.""" with db.session.begin_nested(): cls.query.filter_by(group=group, user_id=user.get_id()).delete()
python
{ "resource": "" }
q262649
Membership.accept
validation
def accept(self): """Activate membership.""" with db.session.begin_nested(): self.state = MembershipState.ACTIVE db.session.merge(self)
python
{ "resource": "" }
q262650
GroupAdmin.create
validation
def create(cls, group, admin): """Create a new group admin. :param group: Group object. :param admin: Admin object. :returns: Newly created GroupAdmin object. :raises: IntegrityError """ with db.session.begin_nested(): obj = cls( group...
python
{ "resource": "" }
q262651
GroupAdmin.get
validation
def get(cls, group, admin): """Get specific GroupAdmin object.""" try: ga = cls.query.filter_by( group=group, admin_id=admin.get_id(), admin_type=resolve_admin_type(admin)).one() return ga except Exception: return None
python
{ "resource": "" }
q262652
GroupAdmin.delete
validation
def delete(cls, group, admin): """Delete admin from group. :param group: Group object. :param admin: Admin object. """ with db.session.begin_nested(): obj = cls.query.filter( cls.admin == admin, cls.group == group).one() db.session.delete(...
python
{ "resource": "" }
q262653
GroupAdmin.query_by_admin
validation
def query_by_admin(cls, admin): """Get all groups for for a specific admin.""" return cls.query.filter_by( admin_type=resolve_admin_type(admin), admin_id=admin.get_id())
python
{ "resource": "" }
q262654
GroupAdmin.query_admins_by_group_ids
validation
def query_admins_by_group_ids(cls, groups_ids=None): """Get count of admins per group.""" assert groups_ids is None or isinstance(groups_ids, list) query = db.session.query( Group.id, func.count(GroupAdmin.id) ).join( GroupAdmin ).group_by( Gr...
python
{ "resource": "" }
q262655
Profiles.all
validation
def all(self): ''' Get all social newtworks profiles ''' response = self.api.get(url=PATHS['GET_PROFILES']) for raw_profile in response: self.append(Profile(self.api, raw_profile)) return self
python
{ "resource": "" }
q262656
Profiles.filter
validation
def filter(self, **kwargs): ''' Based on some criteria, filter the profiles and return a new Profiles Manager containing only the chosen items If the manager doen't have any items, get all the profiles from Buffer ''' if not len(self): self.all() new_list = filter(lambda item:...
python
{ "resource": "" }
q262657
zjitter
validation
def zjitter(jitter=0.0, radius=5): """ scan jitter is in terms of the fractional pixel difference when moving the laser in the z-direction """ psfsize = np.array([2.0, 1.0, 3.0]) # create a base image of one particle s0 = init.create_single_particle_state(imsize=4*radius, radiu...
python
{ "resource": "" }
q262658
Update.interactions
validation
def interactions(self): ''' Returns the detailed information on individual interactions with the social media update such as favorites, retweets and likes. ''' interactions = [] url = PATHS['GET_INTERACTIONS'] % self.id response = self.api.get(url=url) for interaction in response['...
python
{ "resource": "" }
q262659
Update.edit
validation
def edit(self, text, media=None, utc=None, now=None): ''' Edit an existing, individual status update. ''' url = PATHS['EDIT'] % self.id post_data = "text=%s&" % text if now: post_data += "now=%s&" % now if utc: post_data += "utc=%s&" % utc if media: media_format ...
python
{ "resource": "" }
q262660
Update.publish
validation
def publish(self): ''' Immediately shares a single pending update and recalculates times for updates remaining in the queue. ''' url = PATHS['PUBLISH'] % self.id return self.api.post(url=url)
python
{ "resource": "" }
q262661
Update.delete
validation
def delete(self): ''' Permanently delete an existing status update. ''' url = PATHS['DELETE'] % self.id return self.api.post(url=url)
python
{ "resource": "" }
q262662
Update.move_to_top
validation
def move_to_top(self): ''' Move an existing status update to the top of the queue and recalculate times for all updates in the queue. Returns the update with its new posting time. ''' url = PATHS['MOVE_TO_TOP'] % self.id response = self.api.post(url=url) return Update(api=self.ap...
python
{ "resource": "" }
q262663
Updates.pending
validation
def pending(self): ''' Returns an array of updates that are currently in the buffer for an individual social media profile. ''' pending_updates = [] url = PATHS['GET_PENDING'] % self.profile_id response = self.api.get(url=url) for update in response['updates']: pending_update...
python
{ "resource": "" }
q262664
Updates.sent
validation
def sent(self): ''' Returns an array of updates that have been sent from the buffer for an individual social media profile. ''' sent_updates = [] url = PATHS['GET_SENT'] % self.profile_id response = self.api.get(url=url) for update in response['updates']: sent_updates.append(...
python
{ "resource": "" }
q262665
Updates.shuffle
validation
def shuffle(self, count=None, utc=None): ''' Randomize the order at which statuses for the specified social media profile will be sent out of the buffer. ''' url = PATHS['SHUFFLE'] % self.profile_id post_data = '' if count: post_data += 'count=%s&' % count if utc: post_...
python
{ "resource": "" }
q262666
Updates.reorder
validation
def reorder(self, updates_ids, offset=None, utc=None): ''' Edit the order at which statuses for the specified social media profile will be sent out of the buffer. ''' url = PATHS['REORDER'] % self.profile_id order_format = "order[]=%s&" post_data = '' if offset: post_data +=...
python
{ "resource": "" }
q262667
Updates.new
validation
def new(self, text, shorten=None, now=None, top=None, media=None, when=None): ''' Create one or more new status updates. ''' url = PATHS['CREATE'] post_data = "text=%s&" % text post_data += "profile_ids[]=%s&" % self.profile_id if shorten: post_data += "shorten=%s&" % shorten ...
python
{ "resource": "" }
q262668
Logger.noformat
validation
def noformat(self): """ Temporarily do not use any formatter so that text printed is raw """ try: formats = {} for h in self.get_handlers(): formats[h] = h.formatter self.set_formatter(formatter='quiet') yield except Exception as e:...
python
{ "resource": "" }
q262669
Logger.set_verbosity
validation
def set_verbosity(self, verbosity='vvv', handlers=None): """ Set the verbosity level of a certain log handler or of all handlers. Parameters ---------- verbosity : 'v' to 'vvvvv' the level of verbosity, more v's is more verbose handlers : string, or list of ...
python
{ "resource": "" }
q262670
generate_sphere
validation
def generate_sphere(radius): """Generates a centered boolean mask of a 3D sphere""" rint = np.ceil(radius).astype('int') t = np.arange(-rint, rint+1, 1) x,y,z = np.meshgrid(t, t, t, indexing='ij') r = np.sqrt(x*x + y*y + z*z) sphere = r < radius return sphere
python
{ "resource": "" }
q262671
local_max_featuring
validation
def local_max_featuring(im, radius=2.5, noise_size=1., bkg_size=None, minmass=1., trim_edge=False): """Local max featuring to identify bright spherical particles on a dark background. Parameters ---------- im : numpy.ndarray The image to identify particles in. radius...
python
{ "resource": "" }
q262672
otsu_threshold
validation
def otsu_threshold(data, bins=255): """ Otsu threshold on data. Otsu thresholding [1]_is a method for selecting an intensity value for thresholding an image into foreground and background. The sel- ected intensity threshold maximizes the inter-class variance. Parameters ---------- ...
python
{ "resource": "" }
q262673
harris_feature
validation
def harris_feature(im, region_size=5, to_return='harris', scale=0.05): """ Harris-motivated feature detection on a d-dimensional image. Parameters --------- im region_size to_return : {'harris','matrix','trace-determinant'} """ ndim = im.ndim #1. Gradient of image ...
python
{ "resource": "" }
q262674
sphere_triangle_cdf
validation
def sphere_triangle_cdf(dr, a, alpha): """ Cumulative distribution function for the traingle distribution """ p0 = (dr+alpha)**2/(2*alpha**2)*(0 > dr)*(dr>-alpha) p1 = 1*(dr>0)-(alpha-dr)**2/(2*alpha**2)*(0<dr)*(dr<alpha) return (1-np.clip(p0+p1, 0, 1))
python
{ "resource": "" }
q262675
sphere_analytical_gaussian_trim
validation
def sphere_analytical_gaussian_trim(dr, a, alpha=0.2765, cut=1.6): """ See sphere_analytical_gaussian_exact. I trimmed to terms from the functional form that are essentially zero (1e-8) for r0 > cut (~1.5), a fine approximation for these platonic anyway. """ m = np.abs(dr) <= cut # only co...
python
{ "resource": "" }
q262676
PlatonicParticlesCollection._tile
validation
def _tile(self, n): """Get the update tile surrounding particle `n` """ pos = self._trans(self.pos[n]) return Tile(pos, pos).pad(self.support_pad)
python
{ "resource": "" }
q262677
PlatonicParticlesCollection._i2p
validation
def _i2p(self, ind, coord): """ Translate index info to parameter name """ return '-'.join([self.param_prefix, str(ind), coord])
python
{ "resource": "" }
q262678
PlatonicParticlesCollection.get_update_tile
validation
def get_update_tile(self, params, values): """ Get the amount of support size required for a particular update.""" doglobal, particles = self._update_type(params) if doglobal: return self.shape.copy() # 1) store the current parameters of interest values0 = self.get_v...
python
{ "resource": "" }
q262679
PlatonicParticlesCollection.update
validation
def update(self, params, values): """ Update the particles field given new parameter values """ #1. Figure out if we're going to do a global update, in which # case we just draw from scratch. global_update, particles = self._update_type(params) # if we are doin...
python
{ "resource": "" }
q262680
PlatonicSpheresCollection.param_particle
validation
def param_particle(self, ind): """ Get position and radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x', 'a']]
python
{ "resource": "" }
q262681
PlatonicSpheresCollection.param_particle_pos
validation
def param_particle_pos(self, ind): """ Get position of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, j) for i in ind for j in ['z', 'y', 'x']]
python
{ "resource": "" }
q262682
PlatonicSpheresCollection.param_particle_rad
validation
def param_particle_rad(self, ind): """ Get radius of one or more particles """ ind = self._vps(listify(ind)) return [self._i2p(i, 'a') for i in ind]
python
{ "resource": "" }
q262683
PlatonicSpheresCollection.add_particle
validation
def add_particle(self, pos, rad): """ Add a particle or list of particles given by a list of positions and radii, both need to be array-like. Parameters ---------- pos : array-like [N, 3] Positions of all new particles rad : array-like [N] ...
python
{ "resource": "" }
q262684
PlatonicSpheresCollection._update_type
validation
def _update_type(self, params): """ Returns dozscale and particle list of update """ dozscale = False particles = [] for p in listify(params): typ, ind = self._p2i(p) particles.append(ind) dozscale = dozscale or typ == 'zscale' particles = set(...
python
{ "resource": "" }
q262685
PlatonicSpheresCollection._tile
validation
def _tile(self, n): """ Get the tile surrounding particle `n` """ zsc = np.array([1.0/self.zscale, 1, 1]) pos, rad = self.pos[n], self.rad[n] pos = self._trans(pos) return Tile(pos - zsc*rad, pos + zsc*rad).pad(self.support_pad)
python
{ "resource": "" }
q262686
PlatonicSpheresCollection.update
validation
def update(self, params, values): """Calls an update, but clips radii to be > 0""" # radparams = self.param_radii() params = listify(params) values = listify(values) for i, p in enumerate(params): # if (p in radparams) & (values[i] < 0): if (p[-2:] == '-a'...
python
{ "resource": "" }
q262687
Slab.rmatrix
validation
def rmatrix(self): """ Generate the composite rotation matrix that rotates the slab normal. The rotation is a rotation about the x-axis, followed by a rotation about the z-axis. """ t = self.param_dict[self.lbl_theta] r0 = np.array([ [np.cos(t), -np.sin(t), 0], ...
python
{ "resource": "" }
q262688
j2
validation
def j2(x): """ A fast j2 defined in terms of other special functions """ to_return = 2./(x+1e-15)*j1(x) - j0(x) to_return[x==0] = 0 return to_return
python
{ "resource": "" }
q262689
calc_pts_hg
validation
def calc_pts_hg(npts=20): """Returns Hermite-Gauss quadrature points for even functions""" pts_hg, wts_hg = np.polynomial.hermite.hermgauss(npts*2) pts_hg = pts_hg[npts:] wts_hg = wts_hg[npts:] * np.exp(pts_hg*pts_hg) return pts_hg, wts_hg
python
{ "resource": "" }
q262690
calc_pts_lag
validation
def calc_pts_lag(npts=20): """ Returns Gauss-Laguerre quadrature points rescaled for line scan integration Parameters ---------- npts : {15, 20, 25}, optional The number of points to Notes ----- The scale is set internally as the best rescaling for a line scan ...
python
{ "resource": "" }
q262691
f_theta
validation
def f_theta(cos_theta, zint, z, n2n1=0.95, sph6_ab=None, **kwargs): """ Returns the wavefront aberration for an aberrated, defocused lens. Calculates the portions of the wavefront distortion due to z, theta only, for a lens with defocus and spherical aberration induced by coverslip mismatch. (The r...
python
{ "resource": "" }
q262692
get_Kprefactor
validation
def get_Kprefactor(z, cos_theta, zint=100.0, n2n1=0.95, get_hdet=False, **kwargs): """ Returns a prefactor in the electric field integral. This is an internal function called by get_K. The returned prefactor in the integrand is independent of which integral is being called; it is a combinat...
python
{ "resource": "" }
q262693
get_K
validation
def get_K(rho, z, alpha=1.0, zint=100.0, n2n1=0.95, get_hdet=False, K=1, Kprefactor=None, return_Kprefactor=False, npts=20, **kwargs): """ Calculates one of three electric field integrals. Internal function for calculating point spread functions. Returns one of three electric field integrals th...
python
{ "resource": "" }
q262694
get_hsym_asym
validation
def get_hsym_asym(rho, z, get_hdet=False, include_K3_det=True, **kwargs): """ Calculates the symmetric and asymmetric portions of a confocal PSF. Parameters ---------- rho : numpy.ndarray Rho in cylindrical coordinates, in units of 1/k. z : numpy.ndarray Z in cyl...
python
{ "resource": "" }
q262695
get_polydisp_pts_wts
validation
def get_polydisp_pts_wts(kfki, sigkf, dist_type='gaussian', nkpts=3): """ Calculates a set of Gauss quadrature points & weights for polydisperse light. Returns a list of points and weights of the final wavevector's distri- bution, in units of the initial wavevector. Parameters ---------- ...
python
{ "resource": "" }
q262696
calculate_linescan_ilm_psf
validation
def calculate_linescan_ilm_psf(y,z, polar_angle=0., nlpts=1, pinhole_width=1, use_laggauss=False, **kwargs): """ Calculates the illumination PSF for a line-scanning confocal with the confocal line oriented along the x direction. Parameters ---------- y : numpy.ndarray Th...
python
{ "resource": "" }
q262697
calculate_linescan_psf
validation
def calculate_linescan_psf(x, y, z, normalize=False, kfki=0.889, zint=100., polar_angle=0., wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal. Make x,y,z __1D__ numpy.arrays, with x the direction along the scan line. (to make the calculation faster sinc...
python
{ "resource": "" }
q262698
calculate_polychrome_linescan_psf
validation
def calculate_polychrome_linescan_psf(x, y, z, normalize=False, kfki=0.889, sigkf=0.1, zint=100., nkpts=3, dist_type='gaussian', wrap=True, **kwargs): """ Calculates the point spread function of a line-scanning confocal with polydisperse dye emission. Make x,y,z __1D__ numpy.arrays, wi...
python
{ "resource": "" }
q262699
wrap_and_calc_psf
validation
def wrap_and_calc_psf(xpts, ypts, zpts, func, **kwargs): """ Wraps a point-spread function in x and y. Speeds up psf calculations by a factor of 4 for free / some broadcasting by exploiting the x->-x, y->-y symmetry of a psf function. Pass x and y as the positive (say) values of the coordinates at ...
python
{ "resource": "" }