[mesa-users] Profile name zero padding
Robert FARMER
rjfarmer at asu.edu
Fri Dec 5 12:54:15 EST 2014
So I have this python library for reading mesa files, taking care of
reading the profiles.index:
Run as:
import readMesa as mp
m=mp.MESA()
m.loadProfile(num=MODEL_NUMBER)
#or
m.loadProfile(prof=PROFILE_NUMBER)
#and then there is an iterator:
prof_iter=m.iterateProfiles()
#iterator can also take a model number range as:
# m.iterateProfiles(rng=[min,max])
#or give it a list of priorities as:
# m.iterateProfiles(priority=[1,2,...])
for x in prof_iter:
#Note the data is returned in the m class not in x!
m.prof_dat[]
The main data is in m.prof_data["COLUMN_NAME"] and the header is in
m.prof_head["COLUMN_NAME"]
Hope it helps
Rob
On Fri, Dec 5, 2014 at 10:08 AM, Josiah Schwab <jwschwab at berkeley.edu>
wrote:
> Hi Ehsan,
>
> > I would like to ask for a new feature regarding the profile names.
> > I find it a bit inconvenient that profile names are not zero padded
> > from left, because when listing the stored profiles in the LOGS
> > directory with “ls” command, or when using “glob” in python to fetch
> > the list of available files, they are no longer returned in the order
> > by which they were produced. E.g. profile11.data will appear after
> > profile1.data, but before profile2.data. Left zero padding resolves
> > this. This makes life easier (and happier :-D) when plotting profiles
> > in sequential order.
>
> As Bill said, the number in the profile isn't a meaningful ordering, so
> from a design standpoint, it makes sense to leave things as is.
>
> But when I'm doing something quick and dirty, I do cheat sometimes and
> use the profile number as a proxy for model order. But it's easy enough
> to sort things in non-lexicographic order that you may not even need to
> bother with zero-padding. Since software versions are numbered without
> leading zeros, most tools have options for this kind of sort.
>
> When using ls, check out the `-v' option:
>
> -v natural sort of (version) numbers within text
>
> which gives you what you want. If you have an old version of ls that
> doesn't support that, you could reverse sort by timestamp `-tr'
>
> In the case of python glob, the order is arbitrary, so you have to sort
> it anyways. You can use "version" sorting here too, or do something
> simple on your own.
>
> import distutils
> files = glob.glob('profile*.data')
> sorted(files, key=distutils.version.LooseVersion)
>
> But of course, the best advice is still to always get the order from
> profiles.index.
>
> Hope that helps,
> Josiah
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> mesa-users mailing list
> mesa-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mesa-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20141205/a460a4ee/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readMesa.py
Type: text/x-python
Size: 3930 bytes
Desc: not available
URL: <https://lists.mesastar.org/pipermail/mesa-users/attachments/20141205/a460a4ee/attachment.py>
More information about the Mesa-users
mailing list