Source

bluewaters.support_files / upload.py

The default branch has multiple heads

Full commit
from yt.mods import *
from yt.utilities.minimal_representation import \
    MinimalStaticOutput, MinimalProjectionData
import h5py
from md5 import md5
import time
import os

pf = load("/scratch/bwoshea/testrun_nest_inline/RD0000/RD0000")

class PFMock(object):
    def __init__(self, base, f):
        md, (a, c) = base._mrep._generate_post()
        for i,v in md.items(): setattr(self, i, v)
        self.cycle = f.filename.split("_")[1]
        # Now we override
        attrs = f["/attributes"].attrs
        self.name = attrs["pf_name"]
        self.current_redshift = attrs["redshift"]
        self.unique_identifier = md5(self._hash).hexdigest()
        self.current_time = attrs["time_seconds"]

    def _hash(self):
        s = "%s_%s" % (self.cycle, self.current_time)
        return md5(s).hexdigest()

class ProjMock(object):
    def __init__(self, pf, f, axis, field, weight_field):
        self.field_data = {}
        self.axis = axis
        self.field = field
        self.weight_field = str(weight_field)
        self.output_hash = pf._hash()
        for fn in ['px', 'py', 'pdx', 'pdy', field]:
            self.field_data[fn] = f["/axis_%02i/%s" % (axis, fn)][:]

f = h5py.File("j_00010234_weighted.h5", "r")
pfm = PFMock(pf, f)
mso = MinimalStaticOutput(pfm)
mso.name = pfm.name
mso.upload()

pm = ProjMock(pf, f, 0, "Density", "Density")
mpj = MinimalProjectionData(pm)
mpj.upload()