<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_site(self, site_name, location_name=None, er_data=None, pmag_data=None):
 """ Create a Site object and add it to self.sites. If a location name is provided, add the site to location.sites as well. """

        if location_name:
            location = self.find_by_name(location_name, self.locations)
            if not location:
                location = self.add_location(location_name)
        else:
            location = None

        ## check all declinations/azimuths/longitudes in range 0=>360.
        #for key, value in er_data.items():
        #    er_data[key] = pmag.adjust_to_360(value, key)

        new_site = Site(site_name, location, self.data_model, er_data, pmag_data)
        self.sites.append(new_site)
        if location:
            location.sites.append(new_site)
        return new_site