Skip to content

Instantly share code, notes, and snippets.

@pshriwise
pshriwise / prelim_status.py
Created May 13, 2016 18:27
A python script for scraping the TOC from a tex file with color values gathered from metadata hidden in latex comments.
import os, subprocess
from pyPdf import PdfFileReader
import traceback
status_colors = {"done":"green",
"in progress":"darkorange",
"pending" : "red",
@pshriwise
pshriwise / total_n_convert.py
Created May 13, 2016 18:32
python script used to add a total source intensity tag from an expanded r2s step 2 source .h5m. Raw
from pyne.mesh import Mesh,IMeshTag
import numpy as np
import sys
m = Mesh(sys.argv[1])
m.source_density_total = IMeshTag(size=1, dtype=float)
@pshriwise
pshriwise / tag_tris_w_norm
Last active October 13, 2016 17:16
A moab program which tags a vertex with a triangle's normal at the center of the triangle for every triangle in the moab instance.
#include "moab/Core.hpp"
#include "moab/Interface.hpp"
#include "moab/CartVect.hpp"
#include "moab/ProgOptions.hpp"
#include <iostream>
#include <assert.h>
#include <string>
@pshriwise
pshriwise / dagmc_preproc.py
Last active December 8, 2016 01:19
Preliminary replacement for dagmc_preproc based on new DAGMC-Trelis plugins
# make sure that trelis/cubit 'bin' directory is added to PYTHONPATH environment variable
import cubit
import sys
import argparse as ap
def import_file(cubit_instance, filename):
extension = filename[-4:]
if extension == ".sat":
file_type = "acis"
@pshriwise
pshriwise / .travis.yml
Last active March 20, 2017 23:51
Script for testing AUDL endpoints
language: python
sudo: required
notifications:
email:
recipients:
- pshriwise@gmail.com
services: docker
install:
- sudo docker pull pshriwise/audl_img
@pshriwise
pshriwise / audl_hockey_assists.py
Created June 20, 2017 21:24
Script for calculating hockey assists by team, game, or for the entire league based on Ulti-Analytics stats
import argparse
from datetime import datetime
import urllib2, json
from pprint import pprint
from tabulate import tabulate
def sum_dicts(a,b):
out_dict = {}
# list of unique key values
all_keys = list(set(a.keys()+b.keys()))
@pshriwise
pshriwise / mats_to_mg.py
Created September 29, 2017 21:00
PyNE script for collapsing MCNP materials to nuclides with multi-group xs's only
# coding: utf-8
# USE: python mats_to_mg.py <mcnp_input_file>
from pyne import mcnp, nucname
from pyne.material import MaterialLibrary, Material
from sys import argv
# load library from
original_library = MaterialLibrary(mcnp.mats_from_inp(argv[1]))
@pshriwise
pshriwise / create_parts.py
Created November 18, 2017 17:51
Script for separating a STEP CAD file into different volumes using Cubit/Trelis
import cubit
import argparse
# dictionary containing the appropriate
# (export_type, file_extension)
@pshriwise
pshriwise / compile_journler_entries.py
Created November 18, 2017 22:28
Python script for compiling Journler Entries into a single document for Marcia
import os
import operator
# collect all entries
class JournalEntry:
def __init__(self, entry_id, entry_date, entry_subject, raw_text_path):
assert(type(entry_id) == int)
assert(os.path.isfile(raw_text_path))
@pshriwise
pshriwise / check-prog.sh
Created May 4, 2018 14:15
Bash script for detecting existence of running program. Reports to user when the program is complete.
#!/bin/bash
#
# Script for reporting program status in bash.
#