Changeset 25459


Ignore:
Timestamp:
08/25/20 05:24:25 (5 years ago)
Author:
bdef
Message:

CHG:further refining to export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py

    r25458 r25459  
    33import time
    44import collections
     5from inspect import isclass, getmodule
    56from os import path, remove
    67
     
    144145                if ncvar is not None:
    145146                    FillVar(ncvar, Var)
     147            # empty fiel, do nothing
    146148            elif md.__dict__[group].__dict__[field] is None:
    147149                print('field md.{}.{} is None'.format(group, field))
    148             # do nothing
    149150            # if it is a masked array
    150151            elif type(md.__dict__[group].__dict__[field]) is np.ma.core.MaskedArray:
     
    158159                    FillVar(ncvar, Var)
    159160            # this is a multi layered group thta should not be an "else"
    160             else:
    161                 NCgroup.__setattr__('classtype', str(group))
     161            elif isclass(type(md.__dict__[group].__dict__[field])):
     162                classtype = getmodule(type(md.__dict__[group])).__name__
     163                NCgroup.__setattr__('classtype', classtype)
    162164                Subgroup = NCgroup.createGroup(str(field))
    163                 if str(group) == 'solidearth' and str(field) == 'settings':
    164                     Subgroup.__setattr__('classtype', 'solidearthsettings')
    165                 else:
    166                     Subgroup.__setattr__('classtype', str(field))
     165                classtype = getmodule(type(md.__dict__[group].__dict__[field])).__name__
     166                Subgroup.__setattr__('classtype', classtype)
    167167                subfields = dict.keys(md.__dict__[group].__dict__[field].__dict__)
    168168                for subfield in subfields:
     
    175175                        if ncvar is not None:
    176176                            FillVar(ncvar, Var)
     177            else:
     178                print("WARNING, md.{}.{} is not treated as it does not fall in one of the existing cases.".format(str(group), str(field)))
     179
    177180    NCData.close()
    178181
Note: See TracChangeset for help on using the changeset viewer.