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
// URP has a tool to convert postprocessing volumes but it doesn't transform the coefficients so the visuals won't look the same | |
// This does the transformation to make them match. | |
private static void ConvertLiftGammaGainValues( VolumeProfile profile ) | |
{ | |
if( profile != null && profile.TryGet( out LiftGammaGain lgg ) && lgg.active ) | |
{ | |
if( lgg.lift.overrideState ) | |
{ | |
lgg.lift.value = new Vector4( Mathf.LinearToGammaSpace( lgg.lift.value.x * 0.2f / 0.15f ), |
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
using UnityEngine; | |
namespace Code.Editor.Utilities | |
{ | |
public static class EditorLayoutUtil | |
{ | |
public enum RectDirection | |
{ | |
Horizontal, | |
Vertical |
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
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
namespace Code.Utilities.Editor | |
{ | |
public class PingableGameObjectList : EditorWindow | |
{ |
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
{ | |
"webapp": { | |
"access": "ANYONE_ANONYMOUS", | |
"executeAs": "USER_DEPLOYING" | |
}, | |
"exceptionLogging": "STACKDRIVER", | |
"oauthScopes": ["https://www.googleapis.com/auth/spreadsheets"], | |
"runtimeVersion": "V8" | |
} |
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
#pragma strict | |
#pragma implicit | |
#pragma downcast | |
var destroyOnLevelLoad:GameObject[]; | |
// For tracking sessions for Blurst | |
static var startRecorded:boolean = false; | |
function Start() |
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
""" | |
Here's a cute example of using Python's builtin difflib support to find a file with the closest matching name | |
""" | |
from difflib import SequenceMatcher | |
# Suppose we have some files (databases here) with a certain naming scheme. | |
db_files = ['out_NDWFS_1425+3254_J_db.hdf5', 'out_NDWFS_1425+3254_H_db.hdf5'] | |
# Now we have several other files (model definitions here) that have a similar naming scheme | |
py_files = ['model_NDWFS_1425+3254_J.py', 'model_NDWFS_1425+3254_H.py'] | |
for db_file in db_files: |
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 pymc as mc | |
import numpy as np | |
import pyfits as pf | |
arr = pf.getdata('stack3_gold.fits') | |
x=y=np.arange(0,71) | |
x,y=np.meshgrid(x,y) | |
err_map = pf.getdata('stack3wht_gold.fits') | |
def model((x,y),arr): | |
amp = mc.Uniform('amp',lower=0,upper=np.amax(arr),doc='Amplitude') |
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 | |
arr = np.arange(100).reshape(4,5,5) | |
indexes = np.arange(5) | |
np.random.shuffle(indexes) | |
dim2shuff = arr[:,indexes,:] | |
dim3shuff = arr[:,:,indexes] |
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 pylab import * | |
def makeApprox(channel,n=20): | |
u,eigVals,vt = svd(channel) | |
approx = zeros_like(channel) | |
# for i in xrange(n): | |
# approx += outer(u[:,i],vt[i,:])*eigVales[i] | |
approx = dot(u[:,:n]*eigVals[:n], vt[:n,:]) | |
## Fractional error in matrix approximation | |
error = sqrt(sum(eigVals[n+1:]**2)/sum(eigVals**2)) |
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
""" | |
This file is made by the user, to set up model components for a Markov Chain | |
Monte Carlo galaxy simulator. | |
For simplicity, I didn't want to force the user to bind everything to variables, | |
or follow some particular naming scheme, or remember to add them to a list, etc. | |
YAML or such seemed like overkill, since python keyword arguments already make it | |
pretty human-readable | |
""" | |
from psfMC.ModelComponents import Sky, PSF, Sersic | |
from psfMC.distributions import Normal, Uniform |
NewerOlder