Class: IngvQuake::EventResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/ingv_quake/resources/events.rb

Overview

The EventResource class is a subclass of the Resource class, providing additional methods for querying earthquake events with specific filters.

Constant Summary

Constants inherited from Resource

Resource::ERROR_MESSAGES

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#get_events_request, #initialize

Constructor Details

This class inherits a constructor from IngvQuake::Resource

Instance Method Details

#between_dates(starttime:, endtime:, **params) ⇒ Array

Queries events that occurred between the specified start and end times.

Parameters:

  • starttime (DateTime)

    The start time for the query.

  • endtime (DateTime)

    The end time for the query.

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



57
58
59
# File 'lib/ingv_quake/resources/events.rb', line 57

def between_dates(starttime:, endtime:, **params)
  send_request({ starttime: format_datetime(starttime), endtime: format_datetime(endtime), **params })
end

#between_magnitude(minmag:, maxmag:, **params) ⇒ Array

Queries events with magnitudes between the specified minimum and maximum values.

Parameters:

  • minmag (Integer, Float)

    The minimum magnitude for the query.

  • maxmag (Float)

    The maximum magnitude for the query.

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



76
77
78
# File 'lib/ingv_quake/resources/events.rb', line 76

def between_magnitude(minmag:, maxmag:, **params)
  send_request({ minmag: minmag, maxmag: maxmag, **params })
end

#starting_from(starttime:, **params) ⇒ Array

Queries events that occurred after the specified start time.

Parameters:

  • starttime (DateTime)

    The start time for the query.

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



66
67
68
# File 'lib/ingv_quake/resources/events.rb', line 66

def starting_from(starttime:, **params)
  send_request({ starttime: format_datetime(starttime), **params })
end

#where(params = {}) ⇒ Array

Returns An array of parsed event objects.

Examples:

Search for BasicInfo events with max magnitude 5 and min depth 3

client = IngvQuake::Client.new
events = client.get_events
events.where(format: 'text', maxmag: 5, mindepth: 3)

Parameters:

  • params (Hash) (defaults to: {})

    options to be used in request

Options Hash (params):

  • :originid (Integer)

    Origin ID of the event.

  • :magnitudeid (Integer)

    Magnitude ID of the event.

  • :starttime (String)

    Query events starting from this date: ‘2023-04-01T15:06:38’.

  • :endtime (String)

    Query events until this date: ‘2023-04-01T15:06:38’.

  • :address (String)

    The address of the central latitude point for a radial search: ‘Roma, via condotti 1’. This is a custom param, not available on the INGV api.

  • :minlat (Float)

    Specify southern boundary for search (in WGS84): 45.492599.

  • :maxlat (Float)

    Specify northern boundary for search (in WGS84): 45.492599.

  • :minlon (Float)

    Specify western boundary for search (in WGS84): 9.19289.

  • :maxlon (Float)

    Specify eastern boundary for search (in WGS84): 9.19289.

  • :lat (Float)

    Specify the central latitude point for a radial search (in WGS84): 45.492599.

  • :lon (Float)

    Specify the central longitude point for a radial search (in WGS84): 9.19289.

  • :minradius (Float)

    Specify minimum distance from the geographic point defined by latitude and longitude (in Degrees).

  • :maxradius (Float)

    Specify maximum distance from the geographic point defined by latitude and longitude (in Degrees).

  • :minradiuskm (Float)

    Specify minimum distance from the geographic point defined by latitude and longitude. Kilometers. This is an INGV extension to the FDSN specification.

  • :maxradiuskm (Float)

    Specify maximum distance from the geographic point defined by latitude and longitude. Kilometers. This is an INGV extension to the FDSN specification.

  • :minmag (Float)

    Limit to events with a magnitude larger than or equal to the specified minimum.

  • :maxmag (Float)

    Limit to events with a magnitude smaller than or equal to the specified maximum.

  • :mindepth (Float)

    Specify minimum depth (kilometers), values increase positively with depth.

  • :maxdepth (Float)

    Specify maximum depth (kilometers), values increase positively with depth.

  • :orderby (String)

    The sorting order for the results. Possible values: ‘time’, ‘time-asc’, ‘magnitude’, ‘magnitude-asc’. Default: ‘time’.

  • :limit (Integer)

    Limit the results to the specified number of events.

  • :offset (Integer)

    Return results starting at the event count specified.

  • :updatedafter (String)

    Limit to events updated after the specified time (useful for synchronizing events).

  • :format (String)

    Specify output format. Possible values: ‘text’, ‘xml’. Default: ‘text’.

  • :eventid (Integer)

    Retrieve an event based on the unique INGV event id.

  • :includeallorigins (Boolean)

    Is used to retrieve all origins associated with each event.

  • :includeallmagnitudes (Boolean)

    Is used to retrieve all magnitudes associated with each event.

  • :includeallstationsmagnitudes (Boolean)

    Is used to retrieve all stations magnitudes associated with each hypocenter.

  • :includearrivals (Boolean)

    Is used to retrieve any associated phase arrival information for each event.

Returns:

  • (Array)

    An array of parsed event objects.



47
48
49
# File 'lib/ingv_quake/resources/events.rb', line 47

def where(params = {})
  send_request(params)
end

#within_last_day(**params) ⇒ Array

Queries events that occurred within the last day.

Parameters:

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



93
94
95
96
# File 'lib/ingv_quake/resources/events.rb', line 93

def within_last_day(**params)
  a_day_ago = DateTime.now.prev_day
  send_request({ starttime: format_datetime(a_day_ago), **params })
end

#within_last_hour(**params) ⇒ Array

Queries events that occurred within the last hour.

Parameters:

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



84
85
86
87
# File 'lib/ingv_quake/resources/events.rb', line 84

def within_last_hour(**params)
  an_hour_ago = DateTime.now - Rational(1, 24)
  send_request({ starttime: format_datetime(an_hour_ago), **params })
end

#within_last_month(**params) ⇒ Array

Queries events that occurred within the last month.

Parameters:

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



111
112
113
114
# File 'lib/ingv_quake/resources/events.rb', line 111

def within_last_month(**params)
  a_month_ago = DateTime.now.prev_month
  send_request({ starttime: format_datetime(a_month_ago), **params })
end

#within_last_week(**params) ⇒ Array

Queries events that occurred within the last week.

Parameters:

  • params (Hash)

    (optional) Additional query parameters (see #where).

Returns:

  • (Array)

    An array of parsed event objects.



102
103
104
105
# File 'lib/ingv_quake/resources/events.rb', line 102

def within_last_week(**params)
  a_week_ago = (DateTime.now - 7)
  send_request({ starttime: format_datetime(a_week_ago), **params })
end