<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_twi(self, rootpath, raw=False, as_int=True):
 """ Saves the topographic wetness index to a file """

        self.twi = np.ma.masked_array(self.twi, mask=self.twi <= 0,
                                      fill_value=-9999)
        #  self.twi = self.twi.filled()
        self.twi[self.flats] = 0
        self.twi.mask[self.flats] = True
        # self.twi = self.flats
        self.save_array(self.twi, None, 'twi', rootpath, raw, as_int=as_int)