#27 | py02 – short explanation on Csv database and Epoch time

Hi guys, I got a bit sick again I think. I am trying to wake up earlier than before, applying some chronotherapy theories. Anyway, I won’t talk about these theories tonight, I need first to make a list of when I woke up and when I go to bed, then analyzing the data with the sunrise and my sleep hours. It will take about one week to know if it really works, but with the few information I got, I can say if it works or not. These theories can probably help me to handle a lot better my depression without medicine and adjust my biological clock.


For tonight, I really tried to learn something new but I got lost internet… Struggling with the Basemap module for matplotlib on Python.
Oh well. I have also run a program that shows the trajectory animation of a taxi through in Japan streets but didn’t fully understand everything.
This article will be a short one. I will talk about the correlation between .csv database and geoplotlib.
I will also explain how to convert DMS coordinates into DD coordinates with some formula.

So, .csv database stand for “comma-separated values”.
It means the database is listed in a: “name”,”value”,”value” way and not in a table way.
In the animation process of geoplotlib, they need 4 values:

taxi_id,lon,lat,timestamp

name_id define the name of the object.
lon and lat define DD coordinates of name_id.
timestamp use the Unix epoch time.

name_id will refer to one object, in this case, it will be a taxi.
longitude and latitude of Decimal Degrees coordinates can be calculated by convert every number to hours.
It litteraly means that you need to change Degrees-Minutes-Seconds in hours with this formula:

Decimal Degrees = degrees + (minutes/60) + (seconds/3600)

Quite simple, isn’t it ?

Timestamp is defined by the beginning of Unix time since 01/01/1970 midnight.
It is the time origin of many Unix system that stores epoch dates as a signed 32bits integer, which means that the time limit of the integer might be the cause of a bug on 19/01/2038. This bug is called: “Year 2038 problem” or “Y2038”. But from what I’ve read, 64bits architecture can now go beyond the 32bits integer limits (and can handle negative decimal) if the developper update the time storage.

Source: https://upload.wikimedia.org/wikipedia/commons/e/e9/Year_2038_problem.gif
(Source -Wikimedia) “Y2038 problem” 

Anyway, the timestamp uses the time in seconds from 01/01/1970, it means that if you want an animation from a .csv database, you need to got many plots coordinates and timestamp for each plots. Here is what it looks like:

Since I haven’t created the code, I won’t put it here, but I will show you an animation later if I can understand a bit better how the code works.

See you around guys !


What I learned:

  • How the timestamp works and what is Unix time.
  • Not a lot… Really.

 

Leave a Reply

Your email address will not be published.