-
Notifications
You must be signed in to change notification settings - Fork 19
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
How to keep track of filenames for field source? #365
Comments
Hi Thibault - good to hear from you. As you've guessed, it's complicated! The short answer to your particular problem is perhaps to manually save the file names straight after the read step: >>> import cf
>>> cf.write(cf.example_field(0), '~/delme.nc')
>>> f = cf.read('~/delme.nc')[0]
>>> f._custom['saved_filenames'] = f.get_filenames()
>>> f._custom['saved_filenames']
{'/home/david/delme.nc'} Doing it this way, by adding it to the I'm can't think of a reason why we couldn't formalise this to, say: >>> f.get_filenames(save=True)
>>> f.saved_filenames # now a reserved attribute
'/home/david/delme.nc' This method with So what are the complications? As usual it's ambiguities and corner cases. If array values have been entirely overwritten ( I final note, which might make all this moot (at least for you!) is that soon we'll be releasing the first Anyway, let us know if you'd like All the best, |
Hi David, Thank you for your detailed reply, as always. 🙂 I think the manual option you suggest is perfectly acceptable. I agree with you that "saved filenames" could be misleading to some if the field has been altered in such a way that it is no longer the same as the one in the file anymore. So it is probably best not to implement it, although it is not up to me to decide! Thank you for your help! |
Hi Sadie, Hi David, 🙂
In
unifhy
we have been usingcf.Field.get_filenames
for a while to track down the source files of the user input fields so that they can be stored in a configuration file for potential later reuse. And I have only recently being faced with the scenario where "If all of the data are in memory then an emptyset
is returned", meaning thatget_filenames
does not return the information we are looking for anymore (unifhy-org/unifhy#80).So, I am wondering:
cf.Field
that always keeps the filenames of a field regardless of whether its data fits in memory?cf-python
to provide such functionality? e.g. not to drop the filenames even if the data fits in memory (I am guessing it wouldn't, otherwise you would already have implemented it 🙂)Thank you in advance for your help,
Thibault
The text was updated successfully, but these errors were encountered: