Exemple #1
0
    def get_wavewatch(self, datetime, location):
        """
        Computes the wave-height at the time and location
        Input:
            datetime in epoch time (numbers)
            location in latitude, longitude: {'Lat': 24.4, 'Lng': -2.5}
        Output:
            wave height in meters
        Side effect: loads the WAVEWATCH dictionary for the YYYYMMDDHH corresponding to
        datetime
        """
        if LOCAL_VS_S3 == 's3':
            foldername = ns.get_s3foldername_from_epoch(
                datetime, weather_type='WAVEWATCH')
            if foldername not in self.WAVEWATCH:
                self.WAVEWATCH[foldername] = ns.get_s3_wavewatch(datetime)
        else:
            foldername = ns.get_local_foldername_from_epoch(
                datetime, weather_type='WAVEWATCH')
            if foldername not in self.WAVEWATCH:
                self.WAVEWATCH[foldername] = ns.get_local_wavewatch(datetime)

        ndx = ns.location_to_wavewatch_index(location)
        return self.WAVEWATCH[foldername][ndx %
                                          len(self.WAVEWATCH[foldername])]
Exemple #2
0
 def get_gfs(self, datetime, location):
     """
     Computes the wind velocity vector at the time and location
     Input:
         datetime in epoch time (numbers)
         location in latitude, longitude: {'Lat': 24.4, 'Lng': -2.5}
     Output:
         ocean wind velocity vector (a tuple): (u, v) in meters/second. u = latitudinal speed
         v = longitudinal speed
     Side effect: loads the GFS dictionary for the YYYYMMDDHH corresponding to
     datetime
     """
     if LOCAL_VS_S3 == 's3':
         foldername = ns.get_s3foldername_from_epoch(datetime,
                                                     weather_type='GFS')
         if foldername not in self.GFS:
             self.GFS[foldername] = ns.get_s3_gfs(datetime)
             #     print(GFS.keys())
             #     print(foldername)
     else:
         foldername = ns.get_local_foldername_from_epoch(datetime,
                                                         weather_type='GFS')
         if foldername not in self.GFS:
             self.GFS[foldername] = ns.get_local_gfs(datetime)
             #     print(GFS.keys())
             #     print(foldername)
     ndx = ns.location_to_gfs_index(location)
     return self.GFS[foldername][ndx % len(self.GFS[foldername])]
Exemple #3
0
 def get_oscar(self, datetime, location):
     """
     Computes the ocean current vector at the time and location
     Input:
         datetime in epoch time (numbers)
         location in latitude, longitude: {'Lat': 24.4, 'Lng': -2.5}
     Output:
         ocean current vector (a tuple): (u, v) in meters/second. u = latitudinal speed
         v = longitudinal speed
     Side effect: loads the OSCAR dictionary for the YYYYMMDD00 corresponding to
     datetime
     """
     if LOCAL_VS_S3 == 's3':
         foldername = ns.get_s3foldername_from_epoch(datetime,
                                                     weather_type='OSCAR')
         if foldername not in self.OSCAR:
             # foldername e.g. 2019060200
             self.OSCAR[foldername] = ns.get_s3_oscar(datetime)
         # print(OSCAR)
     else:
         foldername = ns.get_local_foldername_from_epoch(
             datetime, weather_type='OSCAR')
         if foldername not in self.OSCAR:
             # foldername e.g. 2019060200
             self.OSCAR[foldername] = ns.get_local_oscar(datetime)
     ndx = ns.location_to_oscar_index(location)
     return self.OSCAR[foldername][ndx % len(self.OSCAR[foldername])]
    def _get_state(self):
        """
        Compute the state tuple. State consists of WAVEWATCH dictionary, GFS dictionary, OSCAR dictionary,
         computed action and observables data record, current location, current timestamp, origin, destination
        :return: state tuple
        """
        if LOCAL_VS_S3 == 's3':
            gfs = ns.get_s3foldername_from_epoch(self.current_timestamp,
                                                 weather_type='GFS')
            oscar = ns.get_s3foldername_from_epoch(self.current_timestamp,
                                                   weather_type='OSCAR')
            ww = ns.get_s3foldername_from_epoch(self.current_timestamp,
                                                weather_type='WAVEWATCH')
        else:
            gfs = ns.get_local_foldername_from_epoch(self.current_timestamp,
                                                     weather_type='GFS')
            oscar = ns.get_local_foldername_from_epoch(self.current_timestamp,
                                                       weather_type='OSCAR')
            ww = ns.get_local_foldername_from_epoch(self.current_timestamp,
                                                    weather_type='WAVEWATCH')

        return np.array(
            self.__expand_observables(self.save_action_observables.values()))