Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple .close(varid, preserve=True) causes a growing 'coordinates' list #4

Closed
jkettleb opened this issue Oct 29, 2013 · 1 comment

Comments

@jkettleb
Copy link
Contributor

It appears that closing files for a variable, but then opening a new file to continue the timeseries can result is a growing coordinates attribute:

$ ncdump -h  /data/local/hadju/test/rlut_Amon_HadCM3_piControl_r1i1p1_200001\-200001.nc  | grep coordinates
  rlut:coordinates = "lat lon" ;
$ ncdump -h  /data/local/hadju/test/rlut_Amon_HadCM3_piControl_r1i1p1_200002\-200002.nc  | grep coordinates
  rlut:coordinates = "lat lon lat lon" ;

A possible fix is to identify in the code where coordinates is appended to and then to replace the append with the C equivalent of something like:

 def add_coord_att(new_coord, coordinates_att):
    '''
    append new_coord to the coordinates_att string

    Examples:
    ---------
    >>> add_coord_att('lat', '')
    'lat'
    >>> add_coord_att('lon', 'lat')
    'lat lon'
    >>> add_coord_att('lat', 'lat lon')
    'lat lon'
    '''
    coords = coordinates_att.split()
    if new_coord not in coords:
         coords.append(new_coord)
    return ' '.join(coords)

It also looks as though the history attribute is getting appended too many times - for instance 'Inverted lat' can appear multiple times. (This is also evident from a review of some CMIP5 data - so this bug has been around for a while).

jkettleb added a commit to jkettleb/cmor that referenced this issue Nov 11, 2013
jkettleb added a commit to jkettleb/cmor that referenced this issue Nov 20, 2013
jkettleb added a commit to jkettleb/cmor that referenced this issue Nov 20, 2013
@doutriaux1
Copy link
Collaborator

I believe this is fixed now that we merged Jamie's patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants