### Install Dependencies and Run ShadowFinder with Poetry Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md Installs Poetry for dependency management, then uses Poetry to install project dependencies, set up pre-commit hooks, run the main tool, and execute tests against various Python versions. ```bash pip install poetry poetry install poetry run pre-commit install poetry run shadowfinder --help poetry run pytest poetry run tox p ``` -------------------------------- ### Clone ShadowFinder Repository and Navigate Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md Clones the ShadowFinder Git repository from GitHub and changes the current directory into the newly cloned project folder, preparing for further setup. ```bash git clone https://github.com/bellingcat/ShadowFinder.git cd ShadowFinder ``` -------------------------------- ### Install ShadowFinder Python Package Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md This command installs the ShadowFinder library from PyPI using pip, making it available for use in Python projects and via its command-line interface. ```shell pip install shadowfinder ``` -------------------------------- ### Find Shadow Locations using CLI with Object Height and Shadow Length Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md This command-line interface example uses `shadowfinder find` to calculate possible shadow locations based on an object's height, shadow length, date, and time. The `time_format` flag specifies if the provided time is UTC or local. ```shell shadowfinder find 10 5 2024-02-29 13:59:59 --time_format=utc ``` -------------------------------- ### Find Shadow Locations using CLI with Sun Altitude Angle Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md This command-line interface example uses `shadowfinder find_sun` to calculate possible shadow locations directly from the sun's altitude angle, along with the date and time. The `time_format` flag specifies if the provided time is UTC or local. ```shell shadowfinder find_sun 50 2024-02-29 13:59:59 --time_format=utc ``` -------------------------------- ### Find Possible Shadow Locations with ShadowFinder Source: https://github.com/bellingcat/shadowfinder/blob/main/ShadowFinderColab.ipynb This Python snippet utilizes the `shadowfinder` library to calculate and visualize potential geographic locations where a shadow of a specified length from an object of a given height could occur at a particular date and time. It supports both UTC and local time inputs, automatically handles the download of necessary data files like 'timezone_grid.json', and installs the 'shadowfinder' dependency if not already present. The script initializes the `ShadowFinder` object, configures it with the provided measurements, computes the shadow locations, and generates a plot of the results, including robust error handling for invalid input parameters. ```python # @title Find a Shadow 🔎 { display-mode: "form" } # @markdown ### ⬅️ Click to find possible locations that match the below information # @markdown Either give object and shadow measurements (at right angles in arbitrary units): object_height = 10 # @param {type:"number"} Height of object in arbitrary units shadow_length = 8 # @param {type:"number"} Length of shadow in arbitrary units # @markdown Or give the elevation angle to the sun directly (in degrees): angle_to_sun = None # @param {type:"number"} Length of shadow in arbitrary units # @markdown Date and time can be given in UTC or local time (set `time type` accordingly), using the time format hh:mm:ss date = "2024-02-29" # @param {type:"date"} time = "12:00:00" # @param {type:"string"} time_type = "utc" # @param ["utc", "local"] # Create output files output = f"./shadowfinder_{object_height}_{shadow_length}_{date}T{time}.png" logfile = f"./shadowfinder_{object_height}_{shadow_length}_{date}T{time}.log" # Imports ![ ! -f "timezone_grid.json" ] && wget https://raw.githubusercontent.com/bellingcat/ShadowFinder/main/timezone_grid.json >> {logfile} 2>&1 ![ ! -f "deps_loaded" ] && pip install shadowfinder >> {logfile} 2>&1 && touch deps_loaded from shadowfinder import ShadowFinder import datetime datetime_date = datetime.datetime.strptime(date, "%Y-%m-%d").date() datetime_time = datetime.datetime.strptime(time, "%H:%M:%S").time() date_time = datetime.datetime.combine( datetime_date, datetime_time ) # Date and time of interest if "finder" not in locals(): finder = ShadowFinder() # check if timezones.npz exists try: finder.load_timezone_grid() except FileNotFoundError: finder.generate_timezone_grid() finder.save_timezone_grid() try: finder.set_details( date_time=date_time, object_height=object_height, shadow_length=shadow_length, time_format=time_type, sun_altitude_angle=angle_to_sun, ) finder.find_shadows() fig = finder.plot_shadows() except (ValueError, AssertionError) as e: print(f"\033[91m{e}\033[0m") ``` -------------------------------- ### Initialize ShadowFinder and Set Scenario Details in Python Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md This Python code demonstrates how to initialize the ShadowFinder class, optionally load or generate a timezone grid for efficiency, and set up the scenario details including date, time, object height, shadow length, and time format. It then runs the shadow calculation and accesses the resulting figure. ```python from shadowfinder import ShadowFinder finder = ShadowFinder() # Use a pre-generated timezone grid to save time # Attempt to load a timezone grid and on a failure generate the grid and save to file try: finder.load_timezone_grid() except FileNotFoundError: finder.generate_timezone_grid() finder.save_timezone_grid() # timezone_grid.json # Set up the scenario # Provide either object_height and shadow_length OR sun_altitude_angle finder.set_details( date_time=date_time, # datetime object with no timezone awareness object_height=object_height, # object height in arbitrary units shadow_length=shadow_length, # shadow length in arbitrary units time_format=time_type, # string, either 'local' or 'utc' sun_altitude_angle=sun_altitude_angle # altitude angle of the sun, in degrees above the horizon ) # Run the finder finder.find_shadows() # Access the resulting figure fig = finder.plot_shadows() ``` -------------------------------- ### Display Help Information for ShadowFinder CLI Commands Source: https://github.com/bellingcat/shadowfinder/blob/main/README.md These commands provide detailed help and usage information for the `find` and `find_sun` subcommands of the ShadowFinder command-line interface, explaining available arguments and options. ```shell shadowfinder find --help ``` ```shell shadowfinder find_sun --help ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.