Events - Thimxx/pyGenealogical-Tools GitHub Wiki
An event refers to a thing of relevance that happens in a specific location during a certain period. This definition describes quite well the concept of event inside pyGenealogicalTools, the event has been implemented as a class and all implementations of the code (Geni, RootsMagic, GEDCOM...) is using this basic class.
Thing of relevance: the things of relevance that today have been implemented are currently "birth", "baptism", "death", "burial", "residence" and "marriage".
Specific location: in genealogy, depending on the data available, the specific location can be known quite accurately (the specific address) or quite wide, only knowing the country.
Certain period: some events might have one and a single date of ocurrance (birth is happenining in a single date, at least covering human race) others might extend several days, or event years (residence). Also, the informaction can be known with difference levels of accuracy:
- "EXACT": the date is quite well known
- "ABOUT": the date is not known or has been calculated thanks to other profiles or events (covers "circa", "about" and "calculated".
- "BETWEEN": the event is known to be contained between 2 dates or the event is a range
- "AFTER" and "BEFORE": the event is only known to be happening before or after a certain date.
Creating a new event
The only needed parameter for creating a new event is to define the specific event:
from pyGenealogy.common_event import event_profile
my_new_event = event_profile("birth")
Only "birth", "baptism", "death", "burial", "residence" and "marriage" are currently available.
Introducing data in the new event
The main data to be introduce is the location and timeframe of the event.
Introducing the location
There are two ways to introduce a new location, either by introducing the "raw" input of the location (a sentence separated by commans) or introducing a dictionary with the data of the event organized.
In order to use properly the option of the location, a key for Mapbox will be needed, as is the library used for geolocating and address.
When introducing a dictionary with the location, they keys accepted in the dictionary are: "raw", "latitude", "longitude", "county", "country", "city", "place_name" and "state". Not all keys are needed.
When a location is added for geolocation, it will always stored the initial sentence in "raw".
In order to access to geolocation services of Mapbox, you should create a key and provide the key to the code.
So... in terms of code goes this way:
from pyGenealogy.common_event import event_profile
from pyGenealogy import set_mapbox_key
import os
my_new_event = event_profile("birth")
#OPTION 1: to introduce the location using geolocation in Mapbox...
#Firstly, introduce the MapBox key either because is an environmental variable (or you create it in code)
os.environ["MAPBOX_API"] = "Introduce here you Mapbox key"
#Or you set using the code (notice, that the code will not create the environmental variable...
set_mapbox_key("Introduce here you Mapbox key")
#Now you can set the location
my_new_event.setLocation("Your address for geolocating here"
#OPTION 2: to introduce the dictionary
my_location = {}
my_location["city"] = "New York"
my_location["country"] = "United States"
my_new_event.setLocationAlreadyProcessed(my_location)
Introducing the date
Date needs to be provide in year, month, day, the accuracy (as described above) and, in case of a range ("BETWEEN" option) also the date in the range. Datetime object is not used as some genealogical dates only contain part of the date (for example, a year, or a year and a month)
from pyGenealogy.common_event import event_profile
my_new_event = event_profile("birth")
my_new_event.setDate(2019, month= 2, day =1 , accuracy = "EXACT")
my_new_event.setDate(2019, accuracy = "ABOUT")
my_new_event.setDate(2019, month= 2, accuracy = "BETWEEN", year_end = 2019, month = 5)
The second date will be always stored as "end". The code automatically will set the oldest date as "end" date but accepts both inputs.
Accessing the data in an event
In order to access all the data several functions are available, either if the event has been created on your own or the event has been obtained from other parts of the code.
#The type of event (i.e. birth)
my_event.get_event_type()
#Get the stored date information
my_event.get_year()
my_event.get_year_end(self)
my_event.get_month()
my_event.get_month_end()
my_event.get_day()
my_event.get_day_end()
my_event.get_accuracy(self)
#Or the date in datetime.date object (only if year, month and day are available)
my_event.get_date()
#Finally, in order to access the location stored a dictionary with all details will be available through this method
my_event.get_location()