@classmethod
def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
    """
        Create an object based on a metadata
        dictionary from tmy2 or tmy3 data readers.

        Parameters
        ----------
        tmy_metadata : dict
            Returned from tmy.readtmy2 or tmy.readtmy3
        tmy_data : None or DataFrame, default None
            Optionally attach the TMY data to this object.

        Returns
        -------
        Location
        """
    tmy2 = tmy_metadata.get('City', False)
    latitude = tmy_metadata['latitude']
    longitude = tmy_metadata['longitude']
    if tmy2:
        name = tmy_metadata['City']
    else:
        name = tmy_metadata['Name']
    tz = tmy_metadata['TZ']
    altitude = tmy_metadata['altitude']
    new_object = cls(latitude, longitude, tz=tz, altitude=altitude, name=
        name, **kwargs)
    if tmy_data is not None:
        new_object.tmy_data = tmy_data
        new_object.weather = tmy_data
    return new_object
