[MITgcm-support] rdmds & error

Martin Losch Martin.Losch at awi.de
Wed Nov 6 08:16:09 EST 2024


Hi Mahdi,

rdmds should work as before, there was no change. For each “*.data” file you also need a “*.meta” file. (e.g. XC.data and XC.meta) for rdmds to work.

Martin

> On 6. Nov 2024, at 12:57, Mahdi Mohammadi <mahdiaragh at yahoo.com> wrote:
> 
> Hi,
> 
> After several years I am updating my scripts using MITgcmutils. Unfortunately, I receive the following errors. I am unsure if these errors are relevant to my grids files, my python3, or ...
> I would be grateful if anybody could advise me.
> Best, Mahdi
> 
> 
> In [4]: XC= MT.rdmds('/media/mahdi/D/IR24/data/grids/XC')
>    ...: 
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:67, in parse1(s)
>      66 try:
> ---> 67     return int(s)
>      68 except ValueError:
> 
> ValueError: invalid literal for int() with base 10: ''
> 
> During handling of the above exception, another exception occurred:
> 
> ParseError                                Traceback (most recent call last)
> Input In [4], in <cell line: 1>()
> ----> 1 XC= MT.rdmds('/media/mahdi/D/IR24/data/grids/XC')
> 
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:337, in rdmds(fnamearg, itrs, machineformat, rec, fill_value, returnmeta, astype, region, lev, usememmap, mm, squeeze, verbose)
>     334 if debug: warning('Found',len(metafiles),'metafiles for iteration',it)
>     336 for metafile in metafiles:
> --> 337     gdims,i0s,ies,timestep,timeinterval,map2gl,meta = readmeta(metafile)
>     338     if arr is None:
>     339         # initialize, allocate
>     340         try:
> 
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:175, in readmeta(f)
>     173 def readmeta(f):
>     174     """ read meta file and extract tile/timestep-specific parameters """
> --> 175     meta = parsemeta(f)
>     176     dimList = meta.pop('dimList')
>     177     # pythonize
> 
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:126, in parsemeta(metafile)
>     122 _currentline = line
>     124 if opening == '[':
>     125     # [] can contain any type of values, separated by commas
> --> 126     val = [ parse1(s) for s in re.split(r',? *',line) ]
>     127 else:
>     128     # {} can only contain single quote-delimited strings separated by space
>     129     val = [ s.rstrip() for s in re.split(r"'  *'", line.strip("'")) ]
> 
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:126, in <listcomp>(.0)
>     122 _currentline = line
>     124 if opening == '[':
>     125     # [] can contain any type of values, separated by commas
> --> 126     val = [ parse1(s) for s in re.split(r',? *',line) ]
>     127 else:
>     128     # {} can only contain single quote-delimited strings separated by space
>     129     val = [ s.rstrip() for s in re.split(r"'  *'", line.strip("'")) ]
> 
> File ~/miniconda3/envs/mysos/lib/python3.10/site-packages/MITgcmutils-0.1.0-py3.10.egg/MITgcmutils/mds.py:69, in parse1(s)
>      67     return int(s)
>      68 except ValueError:
> ---> 69     raise ParseError("Cannot parse value: " + s)
> 
> ParseError: in metafile: Cannot parse value: 
> in: 2
> 
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20241106/b5f723d1/attachment-0001.html>


More information about the MITgcm-support mailing list