Comments (11)
The built-in datetime only works for years > 1. The 'phony' datetime objects are needed to support other calendars besides proleptic_gregorian, and years < 1. They do not contain all the functionality of the the built-in python datetime objects.
from cftime.
Ah, the years makes sense.
Is there an exhaustive (or even partial) list of what functionality the netcdftime objects do not contain from built-in python datetime objects?
from cftime.
netcdftime.datetime only has strftime, replace, timetuple, repr, to_tuple, __richcmp__
from cftime.
netcdftime.datetime only has strftime, replace, timetuple, repr, to_tuple,
__richcmp__
netcdftime.datetime
also implements __sub__
, __add__
, and __radd__
(see Unidata/netcdf4-python#593).
from cftime.
I'm more curious about what netcdftime.datetime is missing, than in what it has.
Could someone answer my question in plain English, if they understand the differences in those terms? I can dir the two and compare myself, but it's a lot of work to go in through code/docstrings and grok what all of these methods are/do. Particularly because the docstrings for these things (including built-in datetime) are not very descriptive. If nobody does, I'll go in and figure it out, and write some documentation so everyone doesn't have to go through this.
One example is that built-in datetimes manage timezones, while netcdftime does not.
from cftime.
I'm telling you what I know. You'll have to compare the methods in python datetime to the methods supplied by netcdf.datetime if you want more.
Note that netcdf.datetime will be a python datetime instance in most cases - only if the python datetime object doesn't support the requested calendar or times will a 'phony' datetime instance be returned.
It would be pretty easy to write a function to request something like a timezone from the object to determine if it's a python datetime object or not.
from cftime.
Thank you for sharing what you know! I wasn't trying to passive-aggressively direct my comment at you, I am genuinely asking if there are others looking at this who can give another answer. Maybe @jhamman, @shoyer, @spencerkclark, @ckhroulev or others know more?
Like I said, I'll go through the methods (likely regardless of responses here), but there are some things that might not be revealed by doing that. I'd like to get as much feedback as I can. For example, Datetime360Day's __init__
docstring is just x.__init__(...) initializes x; see help(type(x)) for signature
, and help(Datetime360Day), and help(type(dt))
shows exactly the same docstring (with no signature). I wouldn't catch that you can't pass in timezones unless I tried it manually or already knew about it.
I've written my own datetime selector as a workaround for the issue where if the current (or older) versions of netcdf4 are installed, the netcdf4 version of netcdftime will be imported. So I'll always know what type I'm returning.
from cftime.
netcdftime.num2date
will create real datetime.datetime
instances when possible (though this may be ill-advised), but netcdftime.datetime
is always it's own class.
I don't think there's much to be done other than looking at the methods right now. Obviously API docs would be nice to have at some point in the future.
Offhand, netcdftime does not support timezones or the alternative datetime constructors (like datetime.today()
) from the datetime module
from cftime.
@mcgibbon - is there more to discuss here?
from cftime.
@jhamman the discussion leads me to think someone should open a new issue for writing complete API docs. But I'll close this one, since I got what answers were available.
from cftime.
Thanks @mcgibbon - additional issues/help developing the documentation would be much appreciated.
from cftime.
Related Issues (20)
- 1.6.0: pytest warnings
- Implement a `strptime` method HOT 12
- New Numpy Version Issues HOT 2
- `cftime.num2date` fails on an empty integer-dtype array
- test_num2date_precision failure on various architectures HOT 3
- OverflowError time values outside range of 64 bit signed integers HOT 13
- Dealing with netcdf time:units with unexpected characters HOT 5
- Future plans for the `longdouble` argument HOT 2
- Support time units that are a multiple of second, hour, or day (with a reference date) HOT 5
- Unexpected results when not using separators in format code with cftime.datetime.strptime HOT 7
- Matplotlib date formatter and cftime : incompatible ? HOT 8
- Parsing "months since ..." dates HOT 4
- Build `musllinux` wheels HOT 4
- Missing 1.6.3 sdist on pypi
- reformat axis, calendar, units or all? Repeating time ranges HOT 1
- Passing empty array to date2num raises `IndexError: index 0 is out of bounds for axis 0 with size 0` HOT 1
- Numpy 2.0 incompatibility
- BUG: Not NumPy 2.0 compatible HOT 9
- PyPI release pulls numpy 2.0.0rc1 for python 3.12 HOT 4
- [Bug]: `TypeError: unsupported operand type(s) for +: 'cftime._cftime.DatetimeNoLeap' and 'NoneType'` on Linux HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cftime.