Ejemplo n.º 1
0
def save_ht_outs(h5_gp, tfp, shift):
    """ Save processed Hilbert Transform outputs"""
    # Error check
    if isinstance(h5_gp, h5py.Dataset):
        raise ValueError('Must pass an h5Py group')

    # Filter bad pixels
    tfp_fixed, _ = badpixels.fix_array(tfp, threshold=2)
    tfp_fixed = np.array(tfp_fixed)

    # write data; note that this is all actually deprecated and should be fixed
    #    grp_name = h5_gp.name
    #    grp_tr = px.io.VirtualGroup(grp_name)
    #    tfp_px = px.io.VirtualDataset('tfp', tfp, parent = h5_gp)
    #    shift_px = px.io.VirtualDataset('shift', shift, parent = h5_gp)
    #    tfp_fixed_px = px.io.VirtualDataset('tfp_fixed', tfp_fixed, parent = h5_gp)
    #
    #    grp_tr.attrs['timestamp'] = get_time_stamp()
    #    grp_tr.add_children([tfp_px])
    #    grp_tr.add_children([shift_px])
    #    grp_tr.add_children([tfp_fixed_px])

    # write data using current pyUSID implementations
    #    grp_tr = h5_file.create_group(h5_gp.name)
    tfp_px = h5_gp.create_dataset('tfp', data=tfp, dtype=np.float32)
    shift_px = h5_gp.create_dataset('shift', data=shift, dtype=np.float32)
    tfp_fixed_px = h5_gp.create_dataset('tfp_fixed',
                                        data=tfp_fixed,
                                        dtype=np.float32)
    h5_gp.attrs['timestamp'] = get_time_stamp()

    return tfp_px, shift_px, tfp_fixed_px
Ejemplo n.º 2
0
def verify_book_keeping_attrs(test_class, h5_obj):
    time_stamp = get_time_stamp()
    in_file = h5_obj.attrs['timestamp']
    test_class.assertEqual(time_stamp[:time_stamp.rindex('_')], in_file[:in_file.rindex('_')])
    test_class.assertEqual(__version__, h5_obj.attrs['pyUSID_version'])
    test_class.assertEqual(socket.getfqdn(), h5_obj.attrs['machine_id'])
    test_class.assertEqual(platform(), h5_obj.attrs['platform'])
Ejemplo n.º 3
0
    def __init__(self, name, parent='/', attrs=None, children=None):
        """
        Parameters
        ----------
        name : String
            Name of the data group
        parent : (Optional) String
            HDF5 path to the parent of this object. Typically used when
            appending to an existing HDF5 file
            Default value assumes that this group sits at the root of the file
        attrs : dict (Optional). Default = None
            Attributes to be attached to the h5py.Group object
         children : VirtualData or list of VirtualData objects. (Optional)
            Children can be a mixture of groups and datasets
        """

        warn('VirtualGroup is available only for legacy purposes and will be REMOVED in a future release.\n'
             'Please consider using a combination of functions in hdf_utils such as create_results_group() instead',
             DeprecationWarning)

        super(VirtualGroup, self).__init__(name, parent, attrs=attrs)
        self.children = list()
        self.attrs['machine_id'] = socket.getfqdn()
        self.attrs['timestamp'] = get_time_stamp()

        self.indexed = False

        if name != '':
            self.indexed = self.name[-1] == '_'

        if children is not None:
            self.add_children(children)
Ejemplo n.º 4
0
    def __init__(self, name, parent='/', attrs=None, children=None):
        """
        Parameters
        ----------
        name : String
            Name of the data group
        parent : (Optional) String
            HDF5 path to the parent of this object. Typically used when
            appending to an existing HDF5 file
            Default value assumes that this group sits at the root of the file
        attrs : dict (Optional). Default = None
            Attributes to be attached to the h5py.Group object
         children : VirtualData or list of VirtualData objects. (Optional)
            Children can be a mixture of groups and datasets
        """

        warn('VirtualGroup is available only for legacy purposes and will be REMOVED in a future release.\n'
             'Please consider using a combination of functions in :module:`pyUSID.io.hdf_utils` such as '
             ':meth:`pyUSID.io.hdf_utils.create_results_group` instead',
             DeprecationWarning)

        super(VirtualGroup, self).__init__(name, parent, attrs=attrs)
        self.children = list()
        self.attrs['machine_id'] = socket.getfqdn()
        self.attrs['timestamp'] = get_time_stamp()

        self.indexed = False

        if name != '':
            self.indexed = self.name[-1] == '_'

        if children is not None:
            self.add_children(children)