예제 #1
0
def sunpath_from_location(
    lat, lon, tz, north, folder, name, log_file, start_date, start_time, end_date,
        end_time, timestep, leap_year, reverse_vectors):
    """Generate a non climate-based sunpath for a location.

    This command also generates a mod file which includes all the modifiers in sunpath.
    mod file is usually used with rcontrib command to indicate the list of modifiers.
    Since rcontrib command has a hard limit of 10,000 modifiers in a single run the files
    will be broken down into multiple files if number of modifiers is more than 10000
    modifiers.
    """
    location = Location()
    location.latitude = lat
    location.longitude = lon
    location.time_zone = tz
    try:
        sp = Sunpath(location, north)
        hoys = get_hoys(start_date, start_time, end_date, end_time, timestep, leap_year)
        sp_files = sp.to_file(
            folder, name, hoys=hoys, leap_year=leap_year, reverse_vectors=reverse_vectors
        )

        files = [
            {'path': os.path.relpath(path, folder), 'full_path': path}
            for path in sp_files['suns']
        ]

        log_file.write(json.dumps(files))
    except Exception:
        _logger.exception('Failed to generate sunpath.')
        sys.exit(1)
    else:
        sys.exit(0)
예제 #2
0
def test_from_individual_values():
    """Test if the command correctly creates location based on individual values"""
    loc = Location()

    new_latitude = 31.4234953
    new_longitude = 72.9492158
    new_time_zone = 5
    new_elevation = 20

    loc.latitude = new_latitude
    loc.longitude = new_longitude
    loc.time_zone = new_time_zone
    loc.elevation = new_elevation

    assert loc.latitude == new_latitude
    assert loc.longitude == new_longitude
    assert loc.time_zone == new_time_zone
    assert loc.elevation == new_elevation
예제 #3
0
    def test_from_individual_values(self):
        """Test if the command correctly creates location based on individual values"""
        loc = Location()

        new_latitude = 31.4234953
        new_longitude = 72.9492158
        new_time_zone = 5
        new_elevation = 20

        loc.latitude = new_latitude
        loc.longitude = new_longitude
        loc.time_zone = new_time_zone
        loc.elevation = new_elevation

        assert loc.latitude == new_latitude
        assert loc.longitude == new_longitude
        assert loc.time_zone == new_time_zone
        assert loc.elevation == new_elevation