EarthFrequencies / earth-frequencies-data

Open data describing the radio frequency allocation for each region and country.
Other
1 stars 1 forks source link

feat(converter): add data converter #1

Closed jrmlhermitte closed 2 years ago

jrmlhermitte commented 2 years ago

Description

This PR attempts to define the data with data models. A conversion tool is also added with tests.

The main features of this PR are:

How to review this PR

The only substantial change here is the addition of data models. The rest is kind of straightforward conversion and CI/CD that can always be changed later. I suggest we focus on the data models as well as the procedure to run the conversion, and so long as tests pass, trust that the rest works fine. See the data models in the next section.

Data Models

@dataclass
class AllocationTable(DataClassJSONMixin):
    name: str
    allocations: List[Allocation]
    metadata: Optional[Dict[str, str]]

@dataclass
class Allocation(DataClassJSONMixin):
    band: FrequencyBand
    service: AllocationService

@dataclass
class FrequencyBand(DataClassJSONMixin):
    lower_frequency: float
    upper_frequency: float

@dataclass
class AllocationService(DataClassJSONMixin):
    applications: Optional[List[str]]
    category: Optional[str]
    # Do we need this for now?
    footnotes: Optional[List[str]]
    region: str
    service: Optional[str]
    sub_table: Optional[str]

Running the conversion

To run the conversion, just call:

./scripts/run_converter.sh

Checklist

For the Future