def inner(int_id): # pylint: disable=missing-docstring new_container = gwy.Container() gwy.gwy_app_data_browser_add(new_container) gwy.gwy_app_data_browser_copy_channel(con, int_id, new_container) file_name = str(m_id) + "_" + str(int_id) + ".gwy" file_out = os.path.join(dir_path, file_name) meta_id = get_meta_ids(new_container)[0] time_extract = new_container[meta_id]["Date"] time_reformat = datetime.strptime(time_extract, "%Y-%m-%d %H:%M:%S") gwy.gwy_app_file_write(new_container, file_out) time_sec = time.mktime(time_reformat.timetuple()) os.utime(file_out, (time_sec, time_sec)) return file_out
def load(filename, mode=None): if not (zipfile.is_zipfile(filename)): return with zipfile.ZipFile(filename, "r") as zp: filenames = zp.namelist() c = gwy.Container() d = gwy.DataField(100, 100, 100, 100, 1) for i in range(100): for j in range(100): d.set_val(i, j, i) # draws linear gradient c.set_object_by_name("/0/data", d) return c
def test_format(self): from SpeckView import Format from SpeckView.BE.Ergebnis import Ergebnis c = gwy.Container() debug = "debug" original = [Ergebnis(3, 5, 7, 11, 1, 1, 1)] Format.set_custom(c, debug, original) resultat = Format.get_custom(c, debug) """ :type: list[Ergebnis.Ergebnis] """ self.assertEqual(len(resultat), len(original)) for n in range(len(original)): alt = original[n] neu = resultat[n] self.assertEqual(neu.amp, alt.amp) self.assertEqual(neu.resfreq, alt.resfreq) self.assertEqual(neu.guete_amp, alt.guete_amp) self.assertEqual(neu.untergrund, alt.untergrund)
def run(container, mode): data_field_id = gwy.gwy_app_data_browser_get_current(gwy.APP_DATA_FIELD_ID) data_field = container[gwy.gwy_app_get_data_key_for_id(data_field_id)] new_container = gwy.Container() gwy.gwy_app_data_browser_add(new_container) # Need to populate container with dummy data, otherwise # gwy_app_data_browser_copy_channel crashes. dummy_id = gwy.gwy_app_data_browser_add_data_field( data_field, new_container, False ) new_id = gwy.gwy_app_data_browser_copy_channel( container, data_field_id, new_container ) gwy.gwy_app_data_browser_select_data_field(new_container, new_id) # Get rid of dummy reference. new_container.remove_by_prefix('/{}/'.format(dummy_id))
def load(filename, mode=None): ### Load returns a container object, initialize here mainC = gwy.Container() ### Load the file into the Nanonispy Grid object grid = Grid(filename) ### Unpack the file for clarity, assuming the header format is constant. dim_x, dim_y = grid.header.get("dim_px") real_x, real_y = grid.header.get("size_xy") pos_x, pos_y = grid.header.get("pos_xy") channels = grid.header.get("channels") num_sweep_signal = grid.header.get("num_sweep_signal") num_parameters = grid.header.get("num_parameters") experimental_parameters = grid.header.get("experimental_parameters") sweep_size = abs( grid.signals.get("sweep_signal")[0] - grid.signals.get("sweep_signal")[-1]) ### Need to be able to load a arbitrary amount of 3D channel data for i in range(len(channels)): ###Create the gwy Brick object and set dim/units tmpBrick = gwy.Brick(dim_x, dim_y, num_sweep_signal, real_x, real_y, sweep_size, 1) tmpBrick.set_si_unit_x(gwy.SIUnit("m")) tmpBrick.set_si_unit_y(gwy.SIUnit("m")) tmpBrick.set_si_unit_z(gwy.SIUnit("V")) if "(V)" in channels[i]: tmpBrick.set_si_unit_w(gwy.SIUnit("V")) else: tmpBrick.set_si_unit_w(gwy.SIUnit("A")) ### Transfer data to grid object volData = grid.signals.get(channels[i]) for x in range(dim_x): for y in range(dim_y): for z in range(num_sweep_signal): tmpBrick.set_val(x, y, z, volData[x, y, z]) ###Load Brick into main Container mainC.set_object_by_name("/brick/" + str(i), tmpBrick) ###Create a preview by slicing the volume data tmpPreviewDataField = gwy.DataField(dim_x, dim_y, real_x, real_y, 1) tmpBrick.extract_plane(tmpPreviewDataField, 0, 0, 0, dim_x, dim_y, -1, True) mainC.set_object_by_name("/brick/" + str(i) + "/preview", tmpPreviewDataField) ### set title of volume data mainC.set_string_by_name("/brick/" + str(i) + "/title", str(channels[i])) ### Make sure data is visible upon loading mainC.set_boolean_by_name("/brick/" + str(i) + "/visible", False) ### TO DO: figure out how to store the meta data in Container ###Load the topograph to display as well topoDataField = gwy.DataField(dim_x, dim_y, real_x, real_y, 1) topo = grid.signals.get('topo') for x in range(dim_x): for y in range(dim_y): topoDataField.set_val(x, y, topo[x, y]) topoDataField.set_si_unit_xy(gwy.SIUnit('m')) topoDataField.set_si_unit_z(gwy.SIUnit('m')) mainC.set_object_by_name("/0/data", topoDataField) mainC.set_string_by_name("/0/data/title", "topo") mainC.set_boolean_by_name("/0/data/visible", True) return mainC