repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
koukyo1994/streamlit-audio
components/__init__.py
<filename>components/__init__.py<gh_stars>1-10 from .augmentation import augmentations_on_wave from .base import * from .plots import waveplot, specshow, waveplot_with_annotation, specshow_with_annotation from .preprocessing import preprocess_on_wave
alanlivio/website
build_tex_partials_from_mkdocs_yml.py
<gh_stars>0 #!/bin/env python import os from jinja2 import FileSystemLoader from latex import jinja2 import yaml def build_tex_partials_from_mkdocs_yml(): # load reseacher data from mkdcos.yml with open('mkdocs.yml', 'r') as file: # ignore mkdocs.yml related emoji using ! yaml.add_m...
kristofbc/physical-interaction-video-prediction
src/models/predict_model.py
<reponame>kristofbc/physical-interaction-video-prediction #!/usr/bin/env python # -*- coding: utf-8 -*- # Predict the next n frames from a trained model # ============================================== import numpy as np import chainer import chainer.functions as F from train_model import Model from train_model impo...
kristofbc/physical-interaction-video-prediction
models/npz_keys.py
<filename>models/npz_keys.py<gh_stars>1-10 import sys import numpy if __name__ == '__main__': with numpy.load(sys.argv[1]) as f: print(f.keys())
kristofbc/physical-interaction-video-prediction
src/models/train_model.py
<filename>src/models/train_model.py #!/usr/bin/env python # -*- coding: utf-8 -*- # Implementation in Chainer of https://github.com/tensorflow/models/tree/master/video_prediction # ============================================================================================== import types import random import math fro...
kristofbc/physical-interaction-video-prediction
src/data/make_dataset.py
# -*- coding: utf-8 -*- import glob import os import click import logging from dotenv import find_dotenv, load_dotenv import tensorflow as tf import numpy as np from PIL import Image import csv from matplotlib import pyplot as plt @click.command() @click.option('--data_dir', type=click.Path(exists=True), default='d...
kristofbc/physical-interaction-video-prediction
src/visualization/visualize.py
<reponame>kristofbc/physical-interaction-video-prediction import sys import os import glob import csv import click import logging import math import numpy as np import matplotlib import matplotlib.pyplot as plt import chainer import chainer.functions as F import chainer.links as L from PIL import Image # Put the ma...
super-ruilei/svcRec_lr
uitls.py
#coding=utf-8 import os, random, json import pickle from math import * import math import sys # 用户字典 UserList = {} # web服务字典 WsList = {} # 生成的偏好矩阵 Pref_TPMatrix = {} Pref_RTMatrix = {} # 原始的访问数据,用来做对比 TPMatrix = [] RTMatrix = [] ##原始数据 RAW_USRLIST = "./dataset1/userlist.txt" RAW_WSLIST = "./dataset1/wslist.txt" ...
super-ruilei/svcRec_lr
source/main.py
import pandas as pd import matplotlib.pyplot as plt import numpy as np def cal_weight(u, v): uIndices, vIndices = np.where(~np.isnan(u)), np.where(~np.isnan(v)) intersect = np.intersect1d(uIndices, vIndices) union = np.union1d(uIndices, vIndices) return len(intersect) / len(union) def calPre(u): t...
mjenior/bipartite_graphs
code/translate_probes.py
<gh_stars>1-10 import sys import os import math exp_data = open(sys.argv[1], 'r') # raw microarray data probeIDs = open(sys.argv[2], 'r') # translation key for probe IDs to genes koIDs = open(sys.argv[3], 'r') # translation key for genes to KOs infile_name = str(sys.argv[1]).split('/')[-1] infile_name = infile_name....
mjenior/bipartite_graphs
code/bipartite_graph.py
# Use: python bipartite_graph.py full_KO_list KOs_with_zscores import sys import os import pickle import math # Set starting path starting_directory = str(os.getcwd()) script_path = str(os.path.dirname(os.path.realpath(__file__))) # Create dictionary for zscores of each KO zscore_infile = open(sys.argv[2], 'r') ...
lucasosouza/udacity-carnd-term1
P3-Behavorial Cloning/neural_net_nvidia.py
# neural_net_nvidia.py from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Convolution2D, MaxPooling2D from keras.layers.normalization import BatchNormalization # dropped # from keras.utils import np_utils # from keras.optimizes import AdamOptimize...
lucasosouza/udacity-carnd-term1
P3-Behavorial Cloning/preprocessing.py
<reponame>lucasosouza/udacity-carnd-term1 # preprocessing.py import pandas as pd import numpy as np from datetime import datetime import cv2 from PIL import Image ######################################## MAIN FUNCTIONS def load_data(): ## 1. load data columns = ['Center Image','Left Image','Right Image','Ste...
lucasosouza/udacity-carnd-term1
P3-Behavorial Cloning/drive.py
import argparse import base64 import json import numpy as np import socketio import eventlet import eventlet.wsgi import time from PIL import Image from PIL import ImageOps from flask import Flask, render_template from io import BytesIO from preprocessing import process_image, center_scale, process_image_nvidia from ...
lucasosouza/udacity-carnd-term1
P3-Behavorial Cloning/model.py
<filename>P3-Behavorial Cloning/model.py # learn.py from preprocessing import * from neural_net import * from json import dump, load import pickle from keras.models import model_from_json from keras.optimizers import Adam from datetime import datetime def main(first_entry=False, correction=None, lr=1e-3): # rea...
lucasosouza/udacity-carnd-term1
exercises/P5-Lessons/sliding_boxes.py
<gh_stars>1-10 import numpy as np import cv2 import matplotlib.pyplot as plt import matplotlib.image as mpimg image = mpimg.imread('bbox-example-image.jpg') # Here is your draw_boxes function from the previous exercise def draw_boxes(img, bboxes, color=(0, 0, 255), thick=6): # Make a copy of the image imcopy ...
lucasosouza/udacity-carnd-term1
P3-Behavorial Cloning/neural_net.py
# neuralnet.py from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import Convolution2D, MaxPooling2D from keras.layers.normalization import BatchNormalization from keras.optimizers import Adam # dropped # from keras.utils import np_utils def baseline_m...
lucasosouza/udacity-carnd-term1
P5-Vehicle Detection/support_func.py
import matplotlib.image as mpimg import cv2 import numpy as np import glob def region_of_interest(img, vertices): """ Applies an image mask. Only keeps the region of the image defined by the polygon formed from `vertices`. The rest of the image is set to black. """ #defining a blank mask t...
LiangJYu/xarray-sentinel
setup.py
<reponame>LiangJYu/xarray-sentinel<filename>setup.py import setuptools # type: ignore setuptools.setup(use_scm_version={"fallback_version": "999"})
LiangJYu/xarray-sentinel
xarray_sentinel/sentinel1.py
<filename>xarray_sentinel/sentinel1.py import os import typing as T import warnings import fsspec # type: ignore import numpy as np import pandas as pd # type: ignore import rioxarray # type: ignore import xarray as xr from xarray_sentinel import conventions, esa_safe def open_calibration_dataset(calibration_pat...
LiangJYu/xarray-sentinel
tests/test_sentinel1.py
<gh_stars>0 import pathlib import tempfile import numpy as np import xarray as xr from xarray_sentinel import sentinel1 DATA_FOLDER = pathlib.Path(__file__).parent / "data" def test_filter_missing_path() -> None: existing_path = ( DATA_FOLDER / "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_...
LiangJYu/xarray-sentinel
xarray_sentinel/conventions.py
<reponame>LiangJYu/xarray-sentinel """CF representation of metadata according to Sentinel-1 Product Specification: S1-RS-MDA-52-7441, DI-MPC-PB, MPC-0240, 3/7, 27/02/2020 See: https://sentinel.esa.int/documents/247904/1877131/Sentinel-1-Product-Specification """ import xarray as xr from . import __version__ GROUP_AT...
friedrichschoene/pegger
pegger/results.py
class ParsingSuccess: def __init__(self, string, rule_type, start_pos, end_pos, children): self.string = string self.rule_type = rule_type self.start_pos = start_pos self.end_pos = end_pos self.children = children @property def match_string(self): r...
friedrichschoene/pegger
tests/test_rules.py
import pytest from pegger.grammar import Grammar from pegger.rules import * def test_grammar(): # {a^n b^n c^n | n \in N} A = Choices() A.add_rule(Sequence('a', A, 'b')) A.add_rule('ab') B = Choices() B.add_rules(Sequence('b', B, 'c'), 'bc') D = Choices(Not(Any()), Sequence(...
friedrichschoene/pegger
pegger/rules.py
<filename>pegger/rules.py from .results import ParsingSuccess class Rule: """ Abstract base class every rule inherits from. This class should not be used directly to generate a grammar. """ def __init__(self): self.memoization_dict = {} def parse(self, string, start_pos =...
friedrichschoene/pegger
pegger/grammar_parser.py
# Pairs are used as parsing success objects. # They consist of a parsing result object (which can be a Boolean) and an end_pos element. from pegger.grammar import Grammar from . import RuleAlias, String, Range, Any, Choices, Sequence, And, Not, ZeroOrMore, OneOrMore, Optional class GrammarDefinitionNotParsableE...
friedrichschoene/pegger
tests/test_grammar_parser.py
import pytest from pegger import grammar_parser def test_end_of_file(): string = '' assert grammar_parser._end_of_file(string, 0) assert grammar_parser._end_of_file(string, 5) string = 'hello' assert not grammar_parser._end_of_file(string, 0) assert not grammar_parser._end_of_fil...
friedrichschoene/pegger
pegger/grammar.py
<gh_stars>1-10 class Grammar: """ Provides parsing methods for a base Rule """ def __init__(self, base_rule): self.base_rule = base_rule def parse(self, string): """ Parses an input string to an abstract syntax tree. Just a wrapper for the parse method of...
friedrichschoene/pegger
pegger/__init__.py
<filename>pegger/__init__.py from .rules import RuleAlias, String, Range, Any, Choices, Sequence, And, Not, ZeroOrMore, OneOrMore, Optional
munirjojoverge/rl_AD_urban_baselines
tests/test_utils.py
import numpy as np from urban_AD_env.utils import rotated_rectangles_intersect def test_rotated_rectangles_intersect(): assert rotated_rectangles_intersect(([12.86076812, 28.60182391], 5.0, 2.0, -0.4675779906495494), ([9.67753944, 28.90585412], 5.0, 2.0, -0.341701936447320...
munirjojoverge/rl_AD_urban_baselines
settings.py
<reponame>munirjojoverge/rl_AD_urban_baselines ###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: January 10, 2019 # Author: <NAME> #############################################...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/vehicle/vehicle_params.py
<filename>urban_AD_env/vehicle/vehicle_params.py ###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: January 10, 2019 # Author: <NAME> ###########################################...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/utils.py
<filename>urban_AD_env/envs/utils.py<gh_stars>1-10 ###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: February 7, 2019 # Author: <NAME> #########################################...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/parking_env.py
from __future__ import division, print_function, absolute_import import numpy as np import pandas from gym import GoalEnv, spaces from urban_AD_env.envs.abstract import AbstractEnv from urban_AD_env.envs.graphics import EnvViewer from urban_AD_env.road.lane import StraightLane, LineType from urban_AD_env.road.road imp...
munirjojoverge/rl_AD_urban_baselines
tests/envs/test_gym.py
<filename>tests/envs/test_gym.py from __future__ import division, print_function import gym import urban_AD_env def test_urban_AD_step(): env = gym.make('urban_AD-v1') env.reset() for i in range(3): action = env.action_space.sample() obs, reward, done, info = env.step(action) env.clo...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/__init__.py
<filename>urban_AD_env/envs/__init__.py from __future__ import absolute_import from urban_AD_env.envs.multilane_env import MultiLaneEnv from urban_AD_env.envs.merge_env import MergeEnv from urban_AD_env.envs.roundabout_env import RoundaboutEnv from urban_AD_env.envs.continuous_env import ContinuousEnv from urban_AD_env...
munirjojoverge/rl_AD_urban_baselines
tests/envs/test.py
import numpy as np OBS_SCALE = 1 REWARD_WEIGHTS = [5/100, 5/100, 1/100, 1/100, 5/10, 5/10] #REWARD_WEIGHTS = [1/100, 1/100, 1/100, 1/100, 1/10, 1/10] SUCCESS_THRESHOLD = 0.15 def distance_2_goal_reward(achieved_goal, desired_goal, p=0.5): return - np.power(np.dot(OBS_SCALE * np.abs(achieved_goal - desired_goal),...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/continuous_multi_env.py
###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: February 7, 2019 # Author: <NAME> ####################################################################### from __future__ imp...
munirjojoverge/rl_AD_urban_baselines
baselines_run.py
###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: February 5, 2019 # Author: <NAME> ####################################################################### import sys, os from...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/build_populate_scenes.py
<reponame>munirjojoverge/rl_AD_urban_baselines<gh_stars>1-10 ###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: February 7, 2019 # Author: <NAME> ##############################...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/continuous_env.py
from __future__ import division, print_function, absolute_import import numpy as np import pandas from gym import GoalEnv, spaces from urban_AD_env.envs.abstract import AbstractEnv from urban_AD_env.road.road import Road, RoadNetwork from urban_AD_env.vehicle.dynamics import Vehicle, Obstacle class ContinuousEnv(Abs...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/envs/sidepass_env.py
<filename>urban_AD_env/envs/sidepass_env.py ###################################################################### # Deep Reinforcement Learning for Autonomous Driving # Created/Modified on: February 7, 2019 # Author: <NAME> ################################################...
munirjojoverge/rl_AD_urban_baselines
tests/pygame_demo.py
# http://richard.cgpublisher.com/product/pub.84/prod.11 # INTIALISATION import pygame, math, sys from pygame.locals import * TURN_SPEED = 5 ACCELERATION = 2 MAX_FORWARD_SPEED = 10 MAX_REVERSE_SPEED = 5 BG= (0,0,0) MAX_Y = 768 MAX_X = 1024 # initialize the screen with size (MAX_X, MAX_Y) screen = pygame.display.set_mo...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/test_basic.py
<filename>urban_AD_env/test_basic.py from __future__ import division, print_function #import gym import sys, os from os.path import dirname, abspath file_path = sys.argv[0] # print('sys.argv[0] =', file_path) #pathname = os.path.dirname(file_path) parent = dirname(dirname(abspath(file_path))) #pri...
munirjojoverge/rl_AD_urban_baselines
urban_AD_env/__init__.py
<filename>urban_AD_env/__init__.py from gym.envs.registration import register register( id='urban_AD-multilane-v1', entry_point='urban_AD_env.envs:MultiLaneEnv', ) register( id='urban_AD-merge-v1', entry_point='urban_AD_env.envs:MergeEnv', ) register( id='urban_AD-roundabout-v1', entry_point=...
imwiwiim90/con_quien_la_veo
data/profesores/crawl.py
import requests from bs4 import BeautifulSoup s = requests.Session() r = s.get('http://ingenieria.javeriana.edu.co/docencia-sistemas') soup = BeautifulSoup(r.text,'html.parser') divs = soup.select(".journal-content-article")[:-3] def save_image(filename,url): r = requests.get(url,stream=True) with open(filename, '...
RI-imaging/ODTbrain
tests/test_alg3d_bppt.py
"""Test tilted backpropagation algorithm""" import numpy as np import odtbrain from common_methods import create_test_sino_3d, create_test_sino_3d_tilted, \ cutout, get_test_parameter_set def test_3d_backprop_phase_real(): sino, angles = create_test_sino_3d() parameters = get_test_parameter_set(2) #...
RI-imaging/ODTbrain
tests/test_processing.py
<reponame>RI-imaging/ODTbrain<gh_stars>10-100 """Tests refractive index conversion techniques""" import sys import numpy as np import odtbrain from odtbrain._prepare_sino import divmod_neg from common_methods import write_results, get_results WRITE_RES = False def get_test_data_set(): """returns 3D array and ...
RI-imaging/ODTbrain
odtbrain/_alg2d_fmp.py
<reponame>RI-imaging/ODTbrain """2D Fourier mapping""" import numpy as np import scipy.interpolate as intp def fourier_map_2d(uSin, angles, res, nm, lD=0, semi_coverage=False, coords=None, count=None, max_count=None, verbose=0): r"""2D Fourier mapping with the Fourier diffraction theorem T...
RI-imaging/ODTbrain
tests/test_angle_weights.py
"""Tests 1D angular weights""" import numpy as np import odtbrain from common_methods import create_test_sino_2d, get_test_parameter_set def test_angle_offset(): """ Tests if things are still correct when there is a 2PI offset in the angles. """ sino, angles = create_test_sino_2d() parameters = ...
RI-imaging/ODTbrain
examples/backprop_from_fdtd_2d.py
"""FDTD cell phantom The *in silico* data set was created with the :abbr:`FDTD (Finite Difference Time Domain)` software `meep`_. The data are 1D projections of a 2D refractive index phantom. The reconstruction of the refractive index with the Rytov approximation is in good agreement with the phantom that was used in ...
RI-imaging/ODTbrain
odtbrain/_alg2d_int.py
"""2D slow integration""" import numpy as np def integrate_2d(uSin, angles, res, nm, lD=0, coords=None, count=None, max_count=None, verbose=0): r"""(slow) 2D reconstruction with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering...
RI-imaging/ODTbrain
odtbrain/_prepare_sino.py
"""Sinogram preparation""" import numpy as np from scipy.stats import mode from skimage.restoration import unwrap_phase def align_unwrapped(sino): """Align an unwrapped phase array to zero-phase All operations are performed in-place. """ samples = [] if len(sino.shape) == 2: # 2D ...
RI-imaging/ODTbrain
odtbrain/apple.py
import multiprocessing as mp import numpy as np import pyfftw import scipy.ndimage as ndi def apple_core_3d(shape, res, nm): r"""Return a binary array with the apple core in 3D Parameters ---------- shape: list-like, length 3 Shape of the reconstruction volume for which to compute th...
RI-imaging/ODTbrain
odtbrain/__init__.py
<reponame>RI-imaging/ODTbrain<filename>odtbrain/__init__.py """Algorithms for scalar diffraction tomography""" from ._alg2d_bpp import backpropagate_2d # noqa F401 from ._alg2d_fmp import fourier_map_2d # noqa F401 from ._alg2d_int import integrate_2d # noqa F401 from ._alg3d_bpp import backpropagate_3d # noqa F40...
RI-imaging/ODTbrain
tests/test_save_memory.py
"""Test save memory options""" import numpy as np import odtbrain from common_methods import create_test_sino_3d, get_test_parameter_set def test_back3d(): sino, angles = create_test_sino_3d(Nx=10, Ny=10) parameters = get_test_parameter_set(2) # complex r = list() for p in parameters: f ...
RI-imaging/ODTbrain
tests/test_weighting.py
"""Test sinogram weighting""" import numpy as np import platform import odtbrain from common_methods import create_test_sino_3d, get_test_parameter_set def test_3d_backprop_weights_even(): """ even weights """ platform.system = lambda: "Windows" sino, angles = create_test_sino_3d() p = get_t...
RI-imaging/ODTbrain
tests/test_spherecoords_from_angles_and_axis.py
<reponame>RI-imaging/ODTbrain<gh_stars>10-100 """3D backpropagation with tilted axis of rotation: sphere coordinates""" import numpy as np import odtbrain import odtbrain._alg3d_bppt def test_simple_sphere(): """simple geometrical tests""" angles = np.array([0, np.pi/2, np.pi]) axes = [[1, 0, 0], [0, 1, ...
RI-imaging/ODTbrain
tests/test_counters.py
"""Tests progress counters""" import multiprocessing as mp import numpy as np import odtbrain from common_methods import create_test_sino_2d, create_test_sino_3d, \ get_test_parameter_set def test_integrate_2d(): sino, angles = create_test_sino_2d(N=10) p = get_test_parameter_set(1)[0] # complex ...
RI-imaging/ODTbrain
tests/test_alg2d_fmp.py
<gh_stars>10-100 """Test Fourier mapping algorithm""" import sys import numpy as np import odtbrain import pytest from common_methods import create_test_sino_2d, cutout, \ get_test_parameter_set, write_results, get_results WRITE_RES = False @pytest.mark.xfail(sys.platform == "darwin", reason="don't know why") ...
RI-imaging/ODTbrain
examples/backprop_from_mie_2d_cylinder_offcenter.py
"""Mie off-center cylinder The *in silico* data set was created with the softare `miefield <https://github.com/RI-imaging/miefield>`_. The data are 1D projections of an off-center cylinder of constant refractive index. The Born approximation is error-prone due to a relatively large radius of the cylinder (30 waveleng...
RI-imaging/ODTbrain
docs/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # project documentation build configuration file, created by # sphinx-quickstart on Sat Feb 22 09:35:49 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # au...
RI-imaging/ODTbrain
examples/backprop_from_fdtd_3d_tilted.py
"""FDTD cell phantom with tilted axis of rotation The *in silico* data set was created with the :abbr:`FDTD (Finite Difference Time Domain)` software `meep`_. The data are 2D projections of a 3D refractive index phantom that is rotated about an axis which is tilted by 0.2 rad (11.5 degrees) with respect to the imaging...
RI-imaging/ODTbrain
tests/test_alg3d_bpp.py
"""Test 3D backpropagation algorithm""" import ctypes import multiprocessing as mp import platform import sys import numpy as np import odtbrain from odtbrain import _alg3d_bpp from common_methods import create_test_sino_3d, cutout, \ get_test_parameter_set, write_results, get_results WRITE_RES = False def te...
RI-imaging/ODTbrain
odtbrain/_alg2d_bpp.py
"""2D backpropagation algorithm""" import numpy as np import scipy.ndimage from . import util def backpropagate_2d(uSin, angles, res, nm, lD=0, coords=None, weight_angles=True, onlyreal=False, padding=True, padval=0, count=None, max_count=None, verbose=0...
RI-imaging/ODTbrain
tests/test_apple.py
<reponame>RI-imaging/ODTbrain """Test apple core correction""" import multiprocessing as mp import sys import numpy as np import odtbrain from common_methods import create_test_sino_3d, cutout, \ get_test_parameter_set, write_results, get_results WRITE_RES = False def test_apple_core_3d_values(): try: ...
RI-imaging/ODTbrain
examples/backprop_from_fdtd_3d.py
<filename>examples/backprop_from_fdtd_3d.py """FDTD cell phantom The *in silico* data set was created with the :abbr:`FDTD (Finite Difference Time Domain)` software `meep`_. The data are 2D projections of a 3D refractive index phantom. The reconstruction of the refractive index with the Rytov approximation is in good a...
RI-imaging/ODTbrain
setup.py
<gh_stars>10-100 from os.path import dirname, realpath, exists from setuptools import setup import sys author = "<NAME>" authors = [author] description = 'Algorithms for diffraction tomography' name = 'odtbrain' year = "2015" sys.path.insert(0, realpath(dirname(__file__))+"/"+name) from _version import version # no...
RI-imaging/ODTbrain
tests/common_methods.py
<reponame>RI-imaging/ODTbrain<filename>tests/common_methods.py """Test helper functions""" import pathlib import tempfile import warnings import zipfile import numpy as np from scipy.ndimage import rotate def create_test_sino_2d(A=9, N=22, max_phase=5.0, ampl_range=(1.0, 1.0)): """ Cr...
RI-imaging/ODTbrain
examples/backprop_from_mie_2d_weights_angles.py
"""Mie cylinder with unevenly spaced angles Angular weighting can significantly improve reconstruction quality when the angular projections are sampled at non-equidistant intervals :cite:`Tam1981`. The *in silico* data set was created with the softare `miefield <https://github.com/RI-imaging/miefield>`_. The data are...
RI-imaging/ODTbrain
tests/test_alg2d_int.py
"""Test slow integration algorithm""" import sys import numpy as np import odtbrain from common_methods import create_test_sino_2d, cutout, \ get_test_parameter_set, write_results, get_results WRITE_RES = False def test_2d_integrate(): myframe = sys._getframe() sino, angles = create_test_sino_2d() ...
RI-imaging/ODTbrain
examples/backprop_from_fdtd_3d_tilted2.py
"""FDTD cell phantom with tilted and rolled axis of rotation The *in silico* data set was created with the :abbr:`FDTD (Finite Difference Time Domain)` software `meep`_. The data are 2D projections of a 3D refractive index phantom that is rotated about an axis which is tilted by 0.2 rad (11.5 degrees) with respect to ...
RI-imaging/ODTbrain
tests/test_alg2d_bpp.py
<filename>tests/test_alg2d_bpp.py """Test 2d backpropagation""" import sys import numpy as np import odtbrain from common_methods import create_test_sino_2d, cutout, \ get_test_parameter_set, write_results, get_results WRITE_RES = False def test_2d_backprop_phase(): myframe = sys._getframe() sino, angl...
RI-imaging/ODTbrain
examples/example_helper.py
<reponame>RI-imaging/ODTbrain<gh_stars>10-100 """Miscellaneous methods for example data handling""" import lzma import os import pathlib import tarfile import tempfile import warnings import zipfile import numpy as np datapath = pathlib.Path(__file__).parent / "data" webloc = "https://github.com/RI-imaging/ODTbrain/...
RI-imaging/ODTbrain
examples/backprop_from_qlsi_3d_hl60.py
<filename>examples/backprop_from_qlsi_3d_hl60.py """HL60 cell The quantitative phase data of an HL60 S/4 cell were recorded using :abbr:`QLSI (quadri-wave lateral shearing interferometry)`. The original dataset was used in a previous publication :cite:`Schuermann2017` to illustrate the capabilities of combined fluores...
RI-imaging/ODTbrain
examples/backprop_from_rytov_3d_phantom_apple.py
"""Missing apple core correction The missing apple core :cite:`Vertu2009` is a phenomenon in diffraction tomography that is a result of the fact the the Fourier space is not filled completely when the sample is rotated only about a single axis. The resulting artifacts include ringing and blurring in the reconstruction...
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
"""3D backpropagation algorithm with a tilted axis of rotation""" import multiprocessing as mp import warnings import numexpr as ne import numpy as np import pyfftw import scipy.ndimage from . import util _ncores = mp.cpu_count() def estimate_major_rotation_axis(loc): """ For a list of points on the unit ...
RI-imaging/ODTbrain
odtbrain/_translate_ri.py
<filename>odtbrain/_translate_ri.py<gh_stars>10-100 """Translate reconstructed object functions to refractive index""" import numpy as np def odt_to_ri(f, res, nm): r"""Convert the ODT object function to refractive index In :abbr:`ODT (Optical Diffraction Tomography)`, the object function is defined by t...
RI-imaging/ODTbrain
tests/test_copy.py
<reponame>RI-imaging/ODTbrain """Test copying arrays""" import numpy as np import odtbrain from common_methods import create_test_sino_3d, get_test_parameter_set def test_back3d(): sino, angles = create_test_sino_3d(Nx=10, Ny=10) p = get_test_parameter_set(1)[0] # complex f1 = odtbrain.backpropagate...
RI-imaging/ODTbrain
examples/backprop_from_mie_2d_incomplete_coverage.py
<gh_stars>10-100 """Mie cylinder with incomplete angular coverage This example illustrates how the backpropagation algorithm of ODTbrain handles incomplete angular coverage. All examples use 100 projections at 100%, 60%, and 40% total angular coverage. The keyword argument `weight_angles` that invokes angular weightin...
RI-imaging/ODTbrain
odtbrain/_alg3d_bpp.py
"""3D backpropagation algorithm""" import ctypes import multiprocessing as mp import numexpr as ne import numpy as np import pyfftw import scipy.ndimage from . import util ncores = mp.cpu_count() mprotate_dict = {} def _cleanup_worker(): if "X" in mprotate_dict: mprotate_dict.pop("X") if "X_shape"...
RI-imaging/ODTbrain
tests/test_rotation_matrices.py
<gh_stars>10-100 """Test 3D backpropagation with tilted axis of ration: matrices""" import numpy as np import odtbrain import odtbrain._alg3d_bppt def test_rotate_points_to_axis(): # rotation of axis itself always goes to y-axis rot1 = odtbrain._alg3d_bppt.rotate_points_to_axis( points=[[1, 2, 3]], a...
RI-imaging/ODTbrain
examples/backprop_from_mie_3d_sphere.py
<filename>examples/backprop_from_mie_3d_sphere.py<gh_stars>10-100 r"""Mie sphere The *in silico* data set was created with the Mie calculation software `GMM-field`_. The data consist of a two-dimensional projection of a sphere with radius :math:`R=14\lambda`, refractive index :math:`n_\mathrm{sph}=1.006`, embedded in a...
karthik-r-rao/parallel-computing-it301
IsingAnnealing/plot.py
<reponame>karthik-r-rao/parallel-computing-it301<gh_stars>0 import matplotlib.pyplot as plt file1 = open("results.txt", "r") file1 = file1.readlines() vertices = [] s_times = [] p_times = [] for line in file1: line = line.split() if line[0][0] == 'S': s_times.append(float(line[2])) vertices....
karthik-r-rao/parallel-computing-it301
IsingAnnealing/check.py
print('\nStarting checker script...') file1 = open("results.txt", "r") file1 = file1.readlines() vertices = [] s_init = [] s_final = [] p_init = [] p_final = [] for line in file1: line = line.split() if line[0][0] == 'S': s_init.append(float(line[3])) s_final.append(float(line[4])) ve...
Sciguy324/Maze-Game-Python
Tilemap Maker/Tilemap Builder.py
<filename>Tilemap Maker/Tilemap Builder.py from tkinter import * from tkinter.messagebox import * from tkinter.filedialog import * from ast import * from shutil import copy2 from os import path import json def build_matrix(width, height): row = [] matrix = [] for i in range(0, width): row.append(0)...
Sciguy324/Maze-Game-Python
Maze (Multiplayer Tests)/Maze (Client 2)/networks.py
# Code from freeCodeCamp.org at https://www.youtube.com/watch?v=McoDjOCb2Zo import socket class Network: def __init__(self): self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.server = input("Enter server IP: ") self.port = 5555 self.addr = (self.server, self.port...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 4/Maze.py
<reponame>Sciguy324/Maze-Game-Python<filename>Maze (Pygame) Checkpoint 4/Maze.py import pygame import os from sys import platform import matplotlib.pyplot as plt import time # Pygame initialization pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.init() # If the platform is windows, ensure that th...
Sciguy324/Maze-Game-Python
Maze (Multiplayer Tests)/Maze (Client 2)/Maze.py
import pygame import os from sys import platform import matplotlib.pyplot as plt import time from networks import * import threading # # PRE-INITIALIZATION: # Pygame initialization pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.init() # If the platform is windows, ensure that the system is not ...
Sciguy324/Maze-Game-Python
Maze (Multiplayer Tests)/Maze (Server 2)/Maze.py
import pygame import os from sys import platform import matplotlib.pyplot as plt import socket # # PRE-INITIALIZATION: # Pygame initialization pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.init() # If the platform is windows, ensure that the system is not stretching the game window to the disp...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 5/dialog.py
import pygame import os pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.init() # Sound initialization talk = pygame.mixer.Sound('sounds/talk.wav') open_dialog = pygame.mixer.Sound('sounds/open_dialog.wav') close_dialog = pygame.mixer.Sound('sounds/close_dialog.wav') #walk = pygame.mixer.Sound('so...
Sciguy324/Maze-Game-Python
Mazes (Graphics.py)/Mazes.py
<reponame>Sciguy324/Maze-Game-Python from graphics import * from math import ceil from levels import * import datetime # Window settup win_height = 64 * 9 # 576 win_width = 64 * 16 # 1024 #light_gray = color_rgb(127, 127, 127) win = GraphWin("Mazes", win_width, win_height, autoflush=False) win.setBackground("b...
Sciguy324/Maze-Game-Python
Mazes (Graphics.py)/levels.py
from graphics import * def build_id_lists(ids, large_size): normal_tile_ids = {} large_tile_ids = {} for i in list(ids.items()): norm_img = Image(Point(0, 0), i[1]) norm_img.img = norm_img.rescale(64) large_img = Image(Point(0, 0), i[1]) large_img.img = large_img.rescale(la...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 1/Maze.py
import pygame import os from worlds import * from sys import platform from sprite import * # If the platform is windows, ensure that the system is not stretching the game window to the display. if platform == "win32": import ctypes ctypes.windll.user32.SetProcessDPIAware() os.environ['SDL_VIDEODRIVER'] = '...
Sciguy324/Maze-Game-Python
Maze (Multiplayer Tests)/Maze (Server 2)/sprite.py
from dialog import * import random from _thread import * import json from math import ceil import time from traceback import print_exc from sys import stdout # # WORLDS MODULE class Tile: """Class for animated tiles""" interval = 50 img_index = 0 colorkey = (200, 50, 200) def __init__(self, file...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 3/sprite.py
import pygame import os import ast from dialog import * import random # Functions for actions def blank(args): '''Default interaction that does absolutely nothing''' def speak(args): '''Basic interaction that causes text to appear''' text_box = TextDialog("assets/dialog_box.png") text_box.display_dial...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 4/sprite.py
import pygame import os from dialog import * import random # Functions for actions def blank(args): '''Default interaction that does absolutely nothing''' def speak(args): '''Basic interaction that causes text to appear''' text_box = TextDialog("assets/dialog_box.png") text_box.display_dialog(args) a...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 4/Maze 2 Test.py
import pygame import os from sys import platform import matplotlib.pyplot as plt import time import threading # Pygame initialization pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.init() # If the platform is windows, ensure that the system is not stretching the game window to the display. if pl...
Sciguy324/Maze-Game-Python
Maze (Pygame) Checkpoint 1/sprite.py
import pygame import os import ast from dialog import * import random # Functions for actions def blank(args): '''Default interaction that does absolutely nothing''' def speak(args): '''Basic interaction that causes text to appear''' text_box = TextDialog("assets/dialog_box.png") text_box.display_dial...
Sciguy324/Maze-Game-Python
Maze (Multiplayer Tests)/Maze (Client 2)/sprite.py
<reponame>Sciguy324/Maze-Game-Python from dialog import * import random import json # # WORLDS MODULE class Tile: """Class for animated tiles""" interval = 50 img_index = 0 colorkey = (200, 50, 200) def __init__(self, file): img = pygame.image.load(os.path.join(file)) # Check whe...