<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def adjust_weights(self,obs_dict=None, obsgrp_dict=None):
 """reset the weights of observation groups to contribute a specified amount to the composite objective function Parameters obs_dict : dict dictionary of obs name,new contribution pairs obsgrp_dict : dict dictionary of obs group name,contribution pairs Note ---- if all observations in a named obs group have zero weight, they will be assigned a non-zero weight so that the request phi contribution can be met. Similarly, any observations listed in obs_dict with zero weight will also be reset """


        self.observation_data.index = self.observation_data.obsnme
        self.res.index = self.res.name

        if obsgrp_dict is not None:
            # reset groups with all zero weights
            obs = self.observation_data
            for grp in obsgrp_dict.keys():
                if obs.loc[obs.obgnme==grp,"weight"].sum() == 0.0:
                    obs.loc[obs.obgnme==grp,"weight"] = 1.0
            res_groups = self.res.groupby("group").groups
            obs_groups = self.observation_data.groupby("obgnme").groups
            self.__reset_weights(obsgrp_dict, res_groups, obs_groups)
        if obs_dict is not None:
            # reset obs with zero weight
            obs = self.observation_data
            for oname in obs_dict.keys():
                if obs.loc[oname,"weight"] == 0.0:
                    obs.loc[oname,"weight"] = 1.0

            #res_groups = self.res.groupby("name").groups
            res_groups = self.res.groupby(self.res.index).groups
            #obs_groups = self.observation_data.groupby("obsnme").groups
            obs_groups = self.observation_data.groupby(self.observation_data.index).groups
            self.__reset_weights(obs_dict, res_groups, obs_groups)