### Install AVWX Engine Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md The easiest way to get started is to download the library from pypi using pip. ```bash python -m pip install avwx-engine ``` -------------------------------- ### Install AVWX Engine with All Dependencies Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/launch.md Command to install the AVWX Engine package with all optional dependencies. ```bash python -m pip install avwx-engine[all] ``` -------------------------------- ### Create Virtual Environment Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Create a virtual environment and install the dependencies. ```bash hatch env create ``` -------------------------------- ### Clone Repository Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Download and install the source code and its development dependencies. ```bash git clone https://github.com/avwx-rest/avwx-engine cd avwx-engine ``` -------------------------------- ### Basic Module Use Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/service.md Example of fetching Australian METARs using the get_service function. ```python # Fetch Australian reports station = 'YWOL' country = 'AU' # can source from avwx.Station.country # Get the station's preferred service and initialize to fetch METARs service = avwx.service.get_service(station, country)('metar') # service is now avwx.service.AUBOM init'd to fetch METARs # Fetch the current METAR report = service.fetch(station) ``` -------------------------------- ### Basic METAR Fetch and Parse Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/launch.md Example of fetching and parsing a METAR report for JFK airport. ```python >>> import avwx >>> jfk_metar = avwx.Metar('KJFK') >>> jfk_metar.update() True >>> jfk_metar.data.flight_rules 'VFR' ``` -------------------------------- ### ScrapeService Example: MAC Service Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/service.md Implementation of a ScrapeService for fetching data from Meteorologia Aeronautica Civil for Colombian stations. ```python class MAC(StationScrape): """Requests data from Meteorologia Aeronautica Civil for Columbian stations""" _url = "http://meteorologia.aerocivil.gov.co/expert_text_query/parse" method = "POST" def _make_url(self, station: str) -> tuple[str, dict]: """Returns a formatted URL and parameters""" return self._url, {"query": f"{self.report_type} {station}"} def _extract(self, raw: str, station: str) -> str: """Extracts the report message using string finding""" return self._simple_extract(raw, f"{station.upper()} ", "=") ``` -------------------------------- ### TAF Fetch, Parse, and Forecast Details Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/launch.md Example of fetching and parsing a TAF report for Honolulu, showing raw data and iterating through forecast periods. ```python >>> import avwx >>> hnl_taf = avwx.Taf('PHNL') >>> hnl_taf.update() True >>> hnl_taf.raw 'PHNL 312058Z 3121/0124 07012G19KT P6SM FEW030 SCT050 FM010500 06007KT P6SM FEW025 SCT045 FM012000 07012G19KT P6SM OVC030 SCT050' >>> len(hnl_taf.data.forecast) 3 >>> for line in hnl_taf.data.forecast: ... print(f"{line.flight_rules} from {line.start_time.dt.strftime('%d-%H:%M')} to {line.end_time.dt.strftime('%d-%H:%M')}") ... VFR from 31-21:00 to 01-05:00 VFR from 01-05:00 to 01-20:00 MVFR from 01-20:00 to 01-24:00 ``` -------------------------------- ### FileService Example: NOAA_NBM Service Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/service.md Implementation of a FileService for requesting forecast data from NOAA NBM FTP servers. ```python class NOAA_NBM(FileService): """Requests forecast data from NOAA NBM FTP servers""" _url = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/blend/prod/blend.{}/{}/text/blend_{}tx.t{}z" _valid_types = ("nbh", "nbs", "nbe") @property def _urls(self) -> Iterator[str]: """Iterates through hourly updates no older than two days""" date = dt.datetime.now(tz=dt.timezone.utc) cutoff = date - dt.timedelta(days=1) while date > cutoff: timestamp = date.strftime(r"%Y%m%d") hour = str(date.hour).zfill(2) yield self.url.format(timestamp, hour, self.report_type, hour) date -= dt.timedelta(hours=1) def _extract(self, station: str, source: TextIO) -> Optional[str]: """Returns report pulled from the saved file""" start = station + " " end = self.report_type.upper() + " GUIDANCE" txt = source.read() txt = txt[txt.find(start) :] txt = txt[: txt.find(end, 30)] lines = [] for line in txt.split("\n"): if "CLIMO" not in line: line = line.strip() if not line: break lines.append(line) return "\n".join(lines) or None ``` -------------------------------- ### METAR Fetch, Parse, and Details Source: https://github.com/avwx-rest/avwx-engine/blob/main/docs/launch.md Example of fetching and parsing a METAR report for JFK, showing raw data, flight rules, summary, and station info. ```python >>> import avwx >>> jfk_metar = avwx.Metar('KJFK') >>> jfk_metar.update() True >>> jfk_metar.raw 'KJFK 281651Z 33021G25KT 10SM FEW060 M08/M23 A3054 RMK AO2 SLP339 T10831228' >>> jfk_metar.data.flight_rules 'VFR' >>> jfk_metar.summary 'Winds NNW-330 at 21kt gusting to 25kt, Vis 10sm, Temp -08C, Dew -23C, Alt 30.54inHg, Few clouds at 6000ft' >>> jfk_metar.station.name 'John F Kennedy International Airport' ``` -------------------------------- ### Basic Usage Example Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Reports use ICAO, IATA, or GPS idents when specifying the desired station. Exceptions are thrown if a potentially invalid ident is given. ```python >>> import avwx >>> >>> metar = avwx.Metar('KJFK') >>> metar.station.name 'John F Kennedy International Airport' >>> metar.update() True >>> metar.data.flight_rules 'IFR' ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md You can also preview local changes during development. ```bash hatch run docs:serve ``` -------------------------------- ### Run Tests Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Testing is managed by hatch which uses pytest and coverage under the hood. ```bash hatch test ``` -------------------------------- ### Code Formatting and Linting Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Code formatting and linting. ```bash hatch fmt ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/avwx-rest/avwx-engine/blob/main/README.md Activate the virtual environment. ```bash hatch shell ```