Skip to content

Instantly share code, notes, and snippets.

View sariths's full-sized avatar

Sarith Subramaniam sariths

View GitHub Profile
@sariths
sariths / pep8it.py
Created May 14, 2016 20:25
Take a string containing documentation (usually a Radiance manpage) and make it PEP8 friendly.
# coding=utf-8
"""
Take a string and make it PEP8 friendly.
"""
from __future__ import division,print_function
#This dictionary will store all the characters present in Radiance and other
# documentation which isn't really compatable with utf type. The values will
# be substituted by relevant ascii characters which can then show up on the
# pyCharm documentation.
@sariths
sariths / bsdfParse.py
Created January 29, 2017 02:34
Hacky parser for BSDF files...Attempt #1
def extractBsdfData(fileName):
with open(fileName) as dataFile:
xmlData=dataFile.read().replace('>',' ').replace('<',' ').replace('/','').replace(',',' ').split()
bsdfDataSet = []
quantDict = {"LBNLKlemsFull":145*145}
numericVal=[]
"""This module contains fixes for radiance files exported through su2rad."""
from __future__ import print_function,division
import shutil
import os
def fixAliasMaterialFile(materialFilePath):
"""
@sariths
sariths / bsdfParseWithXML.py
Created April 21, 2017 01:35
Parsing BSDF files with Python using xml library.
from xml.etree import ElementTree
import cPickle,os,json
def getXmlData(fileName):
xmlData = ElementTree.parse(fileName)
node = xmlData.find('./{http://windows.lbl.gov}ScatteringData')
for idx,node in enumerate(xmlData.iter()):
if node.text:
tagVal = node.tag.replace('{http://windows.lbl.gov}', '').strip()
@sariths
sariths / resetExposure.py
Created October 5, 2017 14:34
A python script to reverse assigned exposure values to an images.
"""
Wrote a python implementation of the c-shell script discussed here:
https://www.radiance-online.org//pipermail/hdri/2011-June/000325.html
"""
# coding=utf-8
from __future__ import division
import os
import warnings
@sariths
sariths / tregenza.py
Created October 11, 2017 18:45
Create colorful tregenza sky patches.
# coding=utf-8
import os
import random
import glob
def renderTregenzaPatches(outputPath='tregenzaPatch.hdr',imgResolution=200,reinhartMF=1,cleanUp=True):
"""
:param outputPath: A filepath where the created image should be written to. Defaults to tregenzaPatch.hdr in the same
directory that the script is being run in.
#!/usr/bin/env bash
#Fun with light tubes !
#Octree
oconv -f materials.rad scene.rad > room.oct
#View Matrix
vwrays -vtv -vp 2.65 -2.05 1 -vd 0.02 1 -0.01 -vu 0 0 1 -vv 35 -vh 59 -vo 3 -x 400 -y 400 -pj 0.7 -c 6 -ff | rfluxmtx -v -ffc `-vtv -vp 2.65 -2.05 1 -vd 0.02 1 -0.01 -vu 0 0 1 -vv 35 -vh 59 -vo 3 -x 400 -y 400 -d` -o matrices/vmtx/%03d.hdr -ab 5 -ad 10000 -lw 1e-5 -c 6 -n 16 - vport/vport.rad -i room.oct
@sariths
sariths / perforationTest.py
Last active October 24, 2017 17:17
Test perforate.cal with accurate direct settings.
# coding=utf-8
import os,multiprocessing
#Create octree for the scene.
os.system("oconv materials.rad room.rad skies/NYC.sky> octrees/scene.oct")
commands1=[]
commands2=[]
commands3=[]
commands4=[]
# coding=utf-8
doeStr="""603900,DZA,ALGIERS,IWEC Data,36.72,3.25,https://energyplus.net/weather-download/africa_wmo_region_1/DZA//DZA_Algiers.603900_IWEC/all,doe,18,517,1718,5800,374,267,66
623870,EGY,Al_Minya,ETMY,28.08,30.73,https://energyplus.net/weather-download/africa_wmo_region_1/EGY//EGY_Al.Minya.623870_ETMY/all,doe,0,47,1136,5462,592,813,710
623180,EGY,Alexandria,ETMY,31.2,29.95,https://energyplus.net/weather-download/africa_wmo_region_1/EGY//EGY_Alexandria.623180_ETMY/all,doe,0,136,1270,6405,606,302,41
624140,EGY,Aswan,ETMY,23.97,32.78,https://energyplus.net/weather-download/africa_wmo_region_1/EGY//EGY_Aswan.624140_ETMY/all,doe,12,183,1212,4181,591,834,1747
624140,EGY,ASWAN,IWEC Data,23.97,32.78,https://energyplus.net/weather-download/africa_wmo_region_1/EGY//EGY_Aswan.624140_IWEC/all,doe,3,141,1385,4103,579,913,1636
623930,EGY,Asyut,ETMY,27.05,31.02,https://energyplus.net/weather-download/africa_wmo_region_1/EGY//EGY_Asyut.623930_ETMY/all,doe,4,304,1476,4956,577,709,734
623660,EGY,CAIRO,IWEC Data,3
# coding=utf-8
"""
id,
country,
station_name,
data_source,
lat,
lon,
http_link,
host,