def main(): recipe_name = input('Recipe Name: ') recipe = Recipe(name=recipe_name) print('Ingredients:') name = input('Name: ') quantity = input('Quantity (eg 200): ') measurement = input('Measurement (eg grams): ') ingredient = recipe.build_ingredient(name, quantity, measurement) recipe.add_ingredient_to_recipe_ingredients(ingredient) print('Instructions:') instruction = input('Instruction: ') recipe.add_instruction_to_recipe_instructions(instruction) print('Recipe: ', recipe.build_recipe()) recipe_book = RecipeBook() recipe_book.add_recipe_to_recipe_book(recipe.build_recipe()) print('Recipe Book: ', recipe_book.view_recipes())
subject_type_label='trafficCounter') attr = AttributeMatcher(provider='uk.gov.dft', label='CountPedalCycles') sub_field_latest = LatestValueField(attribute_matcher=attr) field_1 = GeographicAggregationField(label='BicycleCount', subject=a_sub, function='sum', field=sub_field_latest) attr_2 = AttributeMatcher(provider='uk.gov.dft', label='CountCarsTaxis') sub_field_latest_2 = LatestValueField(attribute_matcher=attr_2) field_2 = GeographicAggregationField(label='CarCount', subject=a_sub, function='sum', field=sub_field_latest_2) arithmetic_field = ArithmeticField(label='BicycleFraction', operation='div', operation_on_field_1=field_1, operation_on_field_2=field_2) # Passing everything to a Dataset Object as a list. Building and running the recipe by # passing as arguments location of DigitalConnector and recipe output location. # The latter needs to be relative to user's home directory. dataset = Dataset(subjects=[main_subject], datasources=[m_datasource_2, m_datasource_3, m_datasource_4], fields=[parent_field, arithmetic_field]) recipe = Recipe(dataset=dataset) recipe.build_recipe( output_location='Desktop/london-cycle-traffic-air-quality.json') recipe.run_recipe( tombolo_path='Desktop/TomboloDigitalConnector', output_path='Desktop/london-cycle-traffic-air-quality.geojson')
from os import path, pardir import sys sys.path.append(path.join(path.dirname(path.realpath(__file__)), pardir)) tombolo_path = 'Desktop/TomboloDigitalConnector' recipe_output_location = 'Desktop/london-no2.json' model_output = 'Desktop/london-no2.geojson' from recipe import Recipe, Field, Datasource, AttributeMatcher, Subject, Match_Rule, LatestValueField, Dataset subjects = Subject(subject_type_label='airQualityControl', provider_label='erg.kcl.ac.uk') datasources = Datasource(importer_class='uk.org.tombolo.importer.lac.LAQNImporter', datasource_id='airQualityControl') attribute_matcher = AttributeMatcher(provider='erg.kcl.ac.uk', label='NO2 40 ug/m3 as an annual me') lvf = LatestValueField(attribute_matcher=attribute_matcher, label='Anual NO2') dataset = Dataset(subjects=[subjects], datasources=[datasources], fields=[lvf]) recipe = Recipe(dataset=dataset) recipe.build_recipe(output_location=recipe_output_location) recipe.run_recipe(tombolo_path=tombolo_path, output_path=model_output)
sys.path.append(path.join(path.dirname(path.realpath(__file__)), pardir)) # Importing all the relevant objects which are necessary from recipe import Dataset, Subject, AttributeMatcher, GeographicAggregationField, LatestValueField, Match_Rule, Datasource, Recipe # Creating match rule for London match_rule = Match_Rule(attribute_to_match_on='label', pattern='E090%') subject = Subject(subject_type_label='localAuthority', provider_label='uk.gov.ons', match_rule=match_rule) # Creating datasource to tell DC which importers to call in order to download dataset datasource_1 = Datasource(importer_class='uk.org.tombolo.importer.ons.OaImporter', datasource_id='localAuthority') datasource_2 = Datasource(importer_class='uk.org.tombolo.importer.dft.TrafficCountImporter', datasource_id= 'trafficCounts', geography_scope=["London"]) # Creating Attribute matcher, which means getting only those values from database where # attribute name is CountPedalCycles attribute_matcher = AttributeMatcher(provider='uk.gov.dft', label='CountPedalCycles') field = LatestValueField(attribute_matcher=attribute_matcher, label='CountPedalCycles') # Creating Subject for Geographic aggregation field subject_2 = Subject(subject_type_label='trafficCounter', provider_label='uk.gov.dft') geo_agg_field = GeographicAggregationField(subject=subject_2, field=field, function='sum', label='SumCountPedalCycles') # Creating the dataset and calling DC to run the recipe dataset = Dataset(subjects=[subject], datasources=[datasource_1, datasource_2], fields=[geo_agg_field]) _recipe = Recipe(dataset=dataset) _recipe.build_recipe(output_location='Desktop/aggregate-traffic-count-data-within-localauthorities.json') _recipe.run_recipe(tombolo_path='Desktop/UptodateProject/TomboloDigitalConnector', output_path='Desktop/aggregate-traffic-count-data-within-localauthorities.geojson')
from os import path, pardir import sys sys.path.append(path.join(path.dirname(path.realpath(__file__)), pardir)) from recipe import Recipe, Field, Datasource, AttributeMatcher, Subject, Match_Rule, LatestValueField, Dataset from Importers import importer_london_air_quality subjects = Subject(subject_type_label='airQualityControl', provider_label='erg.kcl.ac.uk') datasources = Datasource(importer_class='', datasource_id='') attribute_matcher = AttributeMatcher(provider='erg.kcl.ac.uk', label='NO2 40 ug/m3 as an annual mean') lvf = LatestValueField(attribute_matcher=attribute_matcher, label='NO2 Value') dataset = Dataset(subjects=[subjects], datasources=[datasources], fields=[lvf]) recipe = Recipe(dataset=dataset) recipe.build_recipe(output_location='Desktop/london-no2-python-importer.json') recipe.run_recipe( tombolo_path='Desktop/UptodateProject/TomboloDigitalConnector', output_path='Desktop/london-no2-python-importer.geojson')