Python Code Documentation

Briefing Module

Base Class

NOTAM briefing.source.base Module

Provides “public” method to define a simple and stable object interface and orchestrate “_private” method that every specific source class should override to implement the specific business logic of the source

class briefing.source.base.NotamSource

Briefing Source base class implementation

Raises:NotImplementedError – raised if the child class has not implemented the overriding of the method
_download_area_briefing()

Should be overrided to perform the business logic required to download a briefing for the specific source.

Raises:NotImplementedError – exception raised if the method is not implemented in the specific source subclass
_login_sequence()

Should be overrided to perform the business logic required to login a user for the specific source.

The full sequence required to login a user to a specific source. This could just be a “pass” if no login is required.

Raises:NotImplementedError – raised if the child class has not implemented the overriding of the method
_logout()

Should be overrided to perform the business logic required to logout from the specific source.

Raises:NotImplementedError – exception raised if the method is not implemented in the specific source subclass
_parse_area_briefing()

Should be overrided to perform the business logic required to parse the briefing raw data for the specific source.

Raises:NotImplementedError – exception raised if the method is not implemented in the specific source subclass
check_active_session()

Test is there is a active session with the specific source

Returns:True if there is an active session
Return type:Bool
download_area_briefing(prefilter)

Trigger the download of a briefing

After the execution of this method, the raw briefing has been retrieved.

Parameters:prefilter ([dict]) – a dictionary with key/value supported by the source to filter NOTAM added to the briefing (see the specific source class documentation)
login(username, password)

Trigger the login operation required by the source.

After the execution of this method, access to the source data should be possible.

Parameters:
  • username ([string]) – credentials information
  • password ([string]) – credentials information
logout()

Trigger the logout operation required by the source.

After the execution of this method, the user access to the source data should not be possible.

parse_area_briefing()

Trigger the parsing of the briefing raw data

Child Class (NATS)

NOTAM briefing.source.nats Module

class briefing.source.nats.NATS

NATS implementation

The NATS specific class will override all the method as described in the base class documentation

Parameters:

NotamSource ([object]) – The NotamSource parent class defining the common interface of all sources

Raises:
  • UserWarning – [description]
  • ValueError – [description]
  • ValueError – [description]
  • an – [description]
Returns:

[description]

Return type:

[type]

Other Parameters:
 
  • lower_fl – ‘0’
  • upper_fl – ‘999’
  • ifr’ – True
  • vfr – True
  • firs – [‘EBBU’, ‘LFFF’]
  • utc_from – datetime.datetime(2018, 9, 12, 12, 0)
  • utc_to – datetime.datetime(2018, 9, 12, 17, 0)
_download_area_briefing()

Should be overrided to perform the business logic required to download a briefing for the specific source.

Raises:NotImplementedError – exception raised if the method is not implemented in the specific source subclass
_login_sequence()

Should be overrided to perform the business logic required to login a user for the specific source.

The full sequence required to login a user to a specific source. This could just be a “pass” if no login is required.

Raises:NotImplementedError – raised if the child class has not implemented the overriding of the method
_parse_area_briefing()

Should be overrided to perform the business logic required to parse the briefing raw data for the specific source.

Raises:NotImplementedError – exception raised if the method is not implemented in the specific source subclass

Notam Module

NOTAM notam.notam Module

exception notam.notam.DecodingError(notam, msg=None)

Exception raised when a NOTAM decoding error is detected

Decoding means building a Notam object based on strings with the expected format and content as provided by the Notam source

Parameters:NotamError (Exception) – NotamError as superclass
class notam.notam.Notam(notam_string_dict)

Main Notam class (purpose of the module)

A NOTAM object is constructed from the string representation of all NOTAM fields a), b), c), e), q), Lower, Upper, Schedule, … with the goal to enhance the programatic value of the NOTAM data present in the briefing.

The relevant python types & data structure are used as much as possible for example:

  • date/datetime
  • Schedule information data (‘b’, ‘c’ & ‘sched’) are expanded as a list of timeslots (i.e. Start/Stop Datetime)
  • some ‘q’ line codes are extracted (admin info, geo-localisation, …)

More info on the qline decoded by the following regex will be provided as class attributes documentation.

Regex:r’(?P<icao>[A-Z]{4}) /Q(?P<subject>[A-Z]{2})(?P<status>[A-Z]{2} /(?P<traffic>[I,V]{1,2}) /(?P<relevance>[N,B,O,M,K]{1,3}) /(?P<scope>A{0,1}E{0,1}W{0,1} /(?P<fl_lower>[0-9]{3} /(?P<fl_upper>[0-9]{3} /(?P<coord_radius>.*)
<icoa>

ICAO location indicator in which the facility, airspace or condition reported on is located (Ex: EBBU, LFFF, …)

Type:str
<subject>

Identify the Subject

  • RR: Restricted Area
  • RD: Danger Area
  • OB: Obstacle

=> The full <subject> requires 2 letters to be fully qualified but the first letter gives already information on a group of subject.

  • R: Nav. Warnings Airspace Resrictions
  • W: Nav. Warnings

We might decide to maintain the full list of code to help in the NOTAM decode exercise in a separate file (easy to maintain in a versioning system)

Type:str
<status>

Define the Status or the Condition of the Subject

  • CA: Changes “Activated”,
  • CD: Changes “Deactivated”,
  • CR: Temporarily “Replaced by,
  • CN: Canceled

=> The full <status> requires 2 letters to be fully qualified but the first letter gives already information on the category of subjects.

  • A: Availability
  • C: Changes
  • H: Hazard
Type:str
<traffic>

Define the “type” traffic affected by the NOTAM (up to 2 letters from the list below)

  • I: IFR
  • V: VFR

As paraglider pilot we are concerned by NOTAM containing a “V” as we flight under the “VFR” rules

Type:str
<relevance>

Define the “relevance” of the NOTAM (up to 3 letters from the list below)

  • N: NOTAM of Immediate attention for flight crew members
  • B: NOTAM selected for PIB entry
  • M: Misceallenous NOTAM
  • K: Checklist NOTAM
  • O: FLight Operations NOTAM

We often see the NBO, BO & M combinations

Type:str
<scope>

Define the “scope” of the NOTAM (up to 2 letters from the list below - note our “simplified” regex)

  • A: Aerodrome
  • E: En-route
  • W: Nav Warning
  • K: Notam in checklist (used ?)
Type:str
<fl_lower>, <fl_upper>

Lower & Upper Limit expressed in Flight Level and rounded down or up to the nearest 100 ft increment

<coord_radius>

Four digits followed by N or S followed by five digits followed by E or W and three digits radius.

This qualifier allows the geographical association of a NOTAM to a facility, service or area that corresponds to the aerodrome or FIR(s) We will further decode this as a real “GEO” information

<sched>

a semantic string representation of a notam schedule.

Supported format are visible in the sched_parser module

Parameters:object ([object]) – superclass
Raises:DecodingError – exception raised when something wrong happen during the decoding phase of the NOTAM
exception notam.notam.NotamError(notam, msg=None)

Exception class building a common message format including NOTAM info

Parameters:Exception (object) – Exception as superclass

Schedule Parser Module

NOTAM notam.sched_parser Module

raises:LexerWarning – Exception raised when a Lexer tokenization error is detected
exception notam.sched_parser.LexerWarning(lexer, token_char)

Exception raised when a Lexer tokenization error is detected

Parameters:PlyError (Exception) – PlyError as superclass
exception notam.sched_parser.PlyError(sched_string, msg=None)

Exception class building a common message format for schedule parser

Parameters:Exception (object) – Exception as superclass
class notam.sched_parser.ScheduleLexer

PLY Lexer for the Schedule field of the NOTAM

Break the schedule text into a collection of tokens specified by a set of regular expression rules.

test(data)

Perform a test execution of the lexer

This method is usefull to check or debug if the tokens regexp matches the input text as expected

Parameters:data ([string]) – schedule input string
class notam.sched_parser.ScheduleParser

PLY Parser for the schedule field of a NOTAM

Each activation slots described by the syntax of the schedule text is expanded as a list of datetime tuple (datetime_start, datetime_stop)

get_schedule()

Retrieve the latest parsed schedule

Returns:list of datetime tupple
Return type:[list]
p_complexdate(p)

complexdate : datelist timeslots | daterange timeslots

p_complexdate_daily(p)

complexdate : DAILY timeslots

p_complexdate_daily_with_exc(p)

complexdate : DAILY timeslots exclusion

p_complexdate_daylist(p)

complexdate : daylist timeslots

p_complexdate_dayrange(p)

complexdate : dayrange timeslots

p_complexdate_partial(p)

complexdate : MONTH DATE AND

p_complexdate_timeslots(p)

complexdate : timeslots

p_complexdate_weekday_range(p)

dayrange : DAY RANGE DAY

p_complexdate_with_exc(p)

complexdate : datelist timeslots exclusion

p_complexdate_with_month(p)

complexdate : MONTH datelist timeslots | MONTH daterange timeslots

p_complexdate_with_month_and_exc(p)

complexdate : MONTH datelist timeslots exclusion

p_complexdate_with_months(p)

complexdate : MONTH DATE RANGE MONTH DATE timeslots

p_complexdatelist_with_months(p)

complexdate : MONTH datelist1 MONTH datelist2 timeslots

p_datelist(p)

datelist : DATE datelist | DATE AND DATE | DATE

p_datelist1(p)

datelist1 : DATE datelist1 | DATE AND DATE | DATE

p_datelist2(p)

datelist2 : DATE datelist2 | DATE AND DATE | DATE

p_daterange(p)

daterange : DATE RANGE DATE

p_daylist(p)

daylist : DAY daylist | DAY AND DAY | DAY

p_exc_weekdays(p)

exc_weekdays : DAY exc_weekdays | HOL exc_weekdays | DAY | HOL

p_exclusion(p)

exclusion : EXC exc_weekdays

p_schedule(p)

schedule : timeslice schedule | timeslice

p_timerange(p)

timerange : HOUR RANGE HOUR | SUNRISE RANGE HOUR | HOUR RANGE SUNSET | SUNRISE RANGE SUNSET | H24

p_timeslice(p)

timeslice : complexdate GROUP | complexdate AND | complexdate

p_timeslots(p)

timeslots : timerange timeslots | timerange

parse(notam_begin, notam_end, data)

Execute the parsing to generate the expanded list of timeslots

Parameters:
  • notam_begin ([datetime]) – the effective start of the NOTAM
  • notam_end ([datetime]) – the effective end of the NOTAM
  • data ([string]) – the schedule string to parse/expand into timeslot
Returns:

list of datetime tupple

Return type:

[list]

Airspace Module

class airspace.aixm_parser.Airspace(source, uuid)

Airspace Interface Abstraction Class

Implement a common set of Airspace method independant from the Source of the Airspace information

parse_airspace()

Execute the parsing of the Airspace to extract Admin & GIS data

exception airspace.aixm_parser.AirspaceGeomUnknown(aixm_source, msg=None)

Exception raised when a AIXM decoding error is detected

Parameters:AixmSourceError (Exception) – AixmSourceError as superclass
class airspace.aixm_parser.AixmSource(filename)

Class to process Airspace information contained in an AIXM 4.5 source file

This class should implement all the method expected by the Airspace class to collect all the relevant information present in the source (admin info, geo info, …) and normalize the return data to our XCTools format

airspace_admin_data(ase_uid)

Extract & normalize the Airspace Admin data

Parameters:ase_uid ([string]) – The UUID ot the Airspace
Returns:the Airspace Admin data as a dictionary
Return type:[dict]
airspace_geometry_data(ase_uid)

Extract & normalize the Airspace GIS data

TODO: cover the creation of the polygon in WKT to make the consumption easier

Parameters:ase_uid ([string]) – The UUID ot the Airspace
Raises:AirspaceGeomUnknown – Exception raised when the GIS data extraction method is not known
Returns:the Airspace GIS data as a list of coordinates that can be used to create a “Polygon”
Return type:[list]
extract_arc_points(direction, arc_center, arc_radius, arc_start, arc_stop)

Extract a subset of Circle points forming a specific Arc of Circle

TODO: confirm the arc_radius needs to be in meter

Parameters:
  • direction ([-1, 1]) – Counter clockwise (-1) or clockwise (1) direction to move on circle
  • arc_center ([lat, long]) – The geo coord. (lat/long) of the Arc center
  • arc_radius ([float]) – The radius of the Arc
  • arc_start ([lat, long]) – The geo coord. (lat/long) of the start point of the Arc
  • arc_stop ([lat, long]) – The geo coord. (lat/long) of the end point of the Arc
Returns:

a list of coordinates that can be used to create a “Polygon”

Return type:

[list]

extract_border_points(gbr_uid, border_start, border_stop)

Get the subset of the relevant border point betwwen a start/stop border points

Similar to the circle case, the border POI are close from the border but will most likely not exist as a border points in the AIXM source

Parameters:
  • gbr_uid ([string]) – The uuid of the relevant border information discovered in the source
  • border_start ([lat, long]) – the first known point on the border
  • border_stop ([lat, long]) – the last known point on the border
Returns:

a list of coordinates that can be used to create an important line of the Airspace polygon (i.e the border)

Return type:

[list]

list_airspace_uuid()

List all Airspace contained in the specific source file

Interface method that needs to be implemented for any source

Returns:
list of dictionary {‘uuid’: file_specific_uuid , ‘name’: airspace_name }
The ‘name’ is provided for convenience or to be used as a natural key across multiple AIXM file if ‘uuid’ is not maintained (time or source)
Return type:list
exception airspace.aixm_parser.AixmSourceError(aixm_source, msg=None)

Exception class building a common message format including AIXM info

Parameters:Exception (object) – Exception as superclass
airspace.aixm_parser.compute_distance(geo_pt1, geo_pt2)

Compute great circle distance between 2 points

TODO: Not really used but we might reuse it to compute the “mean” circle radius

Parameters:
  • geo_center ([latitude, longitude]) – the geo coordinates of the first point
  • geo_point ([latitude, longitude]) – the geo coordinates of the second point
airspace.aixm_parser.dms2dd(degree, minute, second, decimal=0)

Degree Minute Second (Decimal) => Decimal Degree

Parameters:
  • degree ([int]) – number or string repr. of integer
  • minute ([int]) – number or string repr. of integer
  • second ([int]) – number or string repr. of integer
  • decimal ([float]) – optional decimal of seconds in the form 0.xxxxx
Returns:

the Decimal Degree

Return type:

[float]

airspace.aixm_parser.format_decimal_degree(coordinate_string)

Detect a coordinate format & perform the transformation to Decimal Degree

Works for string representation of Latitude or Longitude

North Latitude & East Longitude return a positive value South Latitude & West Longitude return a negative value

Parameters:coordinate_string ([str]) – the input coordinate string that we will auto-detect
Returns:a decimal degree coordinate value
Return type:[float]