This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet debug page</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.css" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.js"></script> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="screen.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
#this accum class is ripped out of some of my other code, I think it should work standalone now | |
#or we just do it another way, we just need a mean^^ | |
class accumulator: | |
''' | |
simple accumulator for large number of data points. allows retrieval of mean and stdev | |
''' | |
def __init__(self, like=None): | |
self._n = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def radial_profile(data, center=None, calcStd=False, os=1): | |
''' | |
calculates a radial profile of ND data around center. will ignore nans | |
calStd: calculate standard deviation, return tuple of (profile, std) | |
os: oversample by a factor. With default 1 the stepsize will be 1 pixel, with 2 it will be .5 pixels etc. | |
''' | |
if center is None: | |
center = np.array(data.shape)//2 | |
if len(center) != data.ndim: | |
raise TypeError('center should be of length data.ndim') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### SETTINGS ###### | |
url= '" | |
username = "" | |
password = "" | |
team_name = "" | |
channel_name = "" | |
####################### | |
import os | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import threading | |
from joblib import Parallel, delayed | |
import Queue | |
import os | |
# Fix print | |
_print = print | |
_rlock = threading.RLock() | |
def print(*args, **kwargs): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
### Requested pixel2q and q2pixel #### | |
def pixel2q(pixel, E_ev, detz_m, pixelsize_m=75e-6): | |
""" | |
returns q in reciprocal nm | |
E_ev: photon Energy in eV | |
detz_m: detector distance in m | |
pixelsize_m: detector pixelsize in m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
from typing import Tuple, Callable | |
class LUT(nn.Module): | |
def __init__(self, f: Callable, dx: float, xrange: Tuple[float, float], mode: str = "linear"): | |
""" | |
LUT of values of a function | |
f: function to use, does not need to be differentiable |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
from typing import Sequence | |
import torch | |
import numpy as np | |
# fzimmermann89, felix.zimmermann@ptb.de, 2024 | |
def sliding_window(x:torch.Tensor, window_shape:int|Sequence[int], axis:None|int|Sequence[int]|=None): | |
"""Sliding window into the tensor x. | |
Returns a view into the tensor x that represents a sliding window. |
OlderNewer