Discussion:
[Gwyddion-users] How to Open Topography first
Andrés Muñiz Piniella
2015-11-30 12:05:55 UTC
Permalink
Hi,
How would I get my SM4 files to open 'Topography' container first?

Is it something i can costumize using pygwy module plugin FILE?
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
David Nečas (Yeti)
2015-11-30 13:01:17 UTC
Permalink
Post by Andrés Muñiz Piniella
How would I get my SM4 files to open 'Topography' container first?
Is it something i can costumize using pygwy module plugin FILE?
I would not try to physically reorder the data as this can mess up
things easily if you miss some bits and pieces.

However, it is possible to set the ‘visible’ flag for some channels upon
loading. When it is set for any channel the data browser will honour
it, instead of showing the first channel which is the default behaviour.

http://gwyddion.net/documentation/user-guide-en/gwyfile-format.html#gwyfile-channels

AFAICT topography is identified by page type = 1. I can modify the
RHK import modules so that they set ‘visible’ flag for all channels that
have this page type (if there are none the default behaviour would
apply).

There should be some general consensus on this behaviour first though.

Otherwise you can essentially override import by writing a module that
- gives higher score than 100 for the RHK SM4 files
- calls the original module to load the file when asked to do it, i.e.
using gwy_file_func_run_load()
- sets ‘visible’ flags accordingly
- returns the modified Container
I did not actually try this so there may be some unexpected hurdles on
the road.

Regards,

Yeti
Andrés Muñiz Piniella
2015-11-30 14:05:29 UTC
Permalink
Post by David Nečas (Yeti)
Post by Andrés Muñiz Piniella
How would I get my SM4 files to open 'Topography' container first?
Is it something i can costumize using pygwy module plugin FILE?
I would not try to physically reorder the data as this can mess up
things easily if you miss some bits and pieces.
However, it is possible to set the ‘visible’ flag for some channels upon
loading. When it is set for any channel the data browser will honour
it, instead of showing the first channel which is the default
behaviour.
http://gwyddion.net/documentation/user-guide-en/gwyfile-format.html#gwyfile-channels
AFAICT topography is identified by page type = 1. I can modify the
RHK import modules so that they set ‘visible’ flag for all channels that
have this page type (if there are none the default behaviour would
apply).
There should be some general consensus on this behaviour first though.
Otherwise you can essentially override import by writing a module that
- gives higher score than 100 for the RHK SM4 files
- calls the original module to load the file when asked to do it, i.e.
using gwy_file_func_run_load()
- sets ‘visible’ flags accordingly
- returns the modified Container
I did not actually try this so there may be some unexpected hurdles on
the road.
Hi yeti,
Sorry for giving the false impression that I knew what I was doing. Is this what you meant?


# in windows7 C:\Users\[NameOfUser]\gwyddion\pygwy

import gwy, sys

 

plugin_type = "FILE"

plugin_desc = "RHK data (.SM4)"

 

 

def detect_by_name(filename):

   if (filename.endswith(".SM4")):

      return 100

   else:

      return 0

 

def load(data, filename, title, mode=None):

   c = gwy.Container()

   for key in data.keys():

      if (title.startswith("Topo")):

         c.set_object_by_name("/0/data/visible", 1)

         #hopefully sets any thing named as topo as visible

         #the default will stay as visible.

 

   return c

 

 
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
David Nečas (Yeti)
2015-12-03 16:02:38 UTC
Permalink
Post by Andrés Muñiz Piniella
Sorry for giving the false impression that I knew what I was doing. Is this what you meant?
I meant more something like this. But DO NOT USE IT. If people need
such terrible hacks we are doing something wrong. So let us instead
have a discussion what should be the default behaviour when opening RHK
files.

Yeti


import gwy, re

plugin_type = "FILE"
plugin_name = "rhk-sm4-wrapper"
plugin_desc = "RHK data (.SM4)"

def detect_by_name(filename):
return 0

def detect_by_content(filename, head, tail, filesize):
if filename.lower().endswith(".sm4"):
return 110
return 0

def load(filename, mode):
c = gwy.gwy_file_func_run_load("rhk-sm4", filename, mode)
for k in c.keys_by_name():
match = re.search(r'^/(\d+)/meta$', k)
if match:
i = int(match.group(1))
m = c['/%d/meta' % i]
if m['Type'] == 'Topographic':
c['/%d/data/visible' % i] = True
return c
Andrés Muñiz Piniella
2015-12-10 09:26:48 UTC
Permalink
OK,
Now understand. RHK lets you put any name for all channels. So unless you can match the name with contains('Topo' OR 'topo'). But I guess this could open specroscopy data.

Not sure how many users of RHK would benefit. I thought this could be a general approach or costumizable.

I've done a script to batch open files and save png with 'topo' and 'pote' as key words. That solves the problem for me. (If I find out how to close the file before opening the next one it would work even better).
Post by David Nečas (Yeti)
Post by Andrés Muñiz Piniella
Sorry for giving the false impression that I knew what I was doing.
Is
Post by Andrés Muñiz Piniella
this what you meant?
I meant more something like this. But DO NOT USE IT. If people need
such terrible hacks we are doing something wrong. So let us instead
have a discussion what should be the default behaviour when opening RHK
files.
Yeti
import gwy, re
plugin_type = "FILE"
plugin_name = "rhk-sm4-wrapper"
plugin_desc = "RHK data (.SM4)"
return 0
return 110
return 0
c = gwy.gwy_file_func_run_load("rhk-sm4", filename, mode)
match = re.search(r'^/(\d+)/meta$', k)
i = int(match.group(1))
m = c['/%d/meta' % i]
c['/%d/data/visible' % i] = True
return c
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for
multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Gwyddion-users mailing list
https://lists.sourceforge.net/lists/listinfo/gwyddion-users
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Loading...