From 3f3754a5e427e6eaec94b7cbc419b152aabb6ce0 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 6 May 2014 14:40:32 +0000 Subject: [PATCH 1/4] Creating more config paramters. Removing unused function sleep. --- www/events.js | 19 ++++++++----------- www/misc.js | 27 +++++++++++++-------------- www/stations.js | 14 ++++++-------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/www/events.js b/www/events.js index bef9f19..cbe7c05 100644 --- a/www/events.js +++ b/www/events.js @@ -25,8 +25,7 @@ /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { if ( !geolocationTable[id] ) { - // $.getJSON( "//nominatim.openstreetmap.org/reverse", { lat: lat, lon: lng, zoom: 10, format: "json" } ) - $.getJSON( "//open.mapquestapi.com/nominatim/v1/reverse.php", { lat: lat, lon: lng, zoom: 10, format: "json" } ) + $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } ) .done(function( json ) { var city = json.address["city"]; var country = json.address["country"]; @@ -57,28 +56,26 @@ function ajaxLoadEvents(stime, etime) { var E = mapBounds.getEast(); var S = mapBounds.getSouth(); var W = mapBounds.getWest(); - var d = 0.1; if ( !stime ) { var stime = new Date(); - stime.setDate(stime.getDate()-180); + stime.setDate(stime.getDate()-config['map']['timespan']); }; if ( !etime ) { var etime = new Date(); etime.setDate(etime.getDate()+1); }; - var url = "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query" var request_data = { starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), endtime: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), - minlat: S-d, - maxlat: N+d, - minlon: W-d, - maxlon: E+d, - minmag: config['event']['minMag']-0.1, + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], + minmag: config['event']['minMag']-config['event']['minMagDelta'], }; $.ajax({ type: "GET", - url: url, + url: config['ajax']['eventURL'], data: request_data, dataType: "xml", success: function (xml) { diff --git a/www/misc.js b/www/misc.js index bdde136..ef40af4 100644 --- a/www/misc.js +++ b/www/misc.js @@ -30,21 +30,9 @@ function mag2radius(mag) { }; /* set height of eventlist div */ -function sleep(milliseconds) { - var start = new Date().getTime(); - for (var i = 0; i < 1e7; i++) { - if ((new Date().getTime() - start) > milliseconds){ - break; - } - } -} - -/* setInfoHeight */ function setInfoHeight() { var height = $('div.map').height() - 36; $('div.info').height(height); - //$('.tab').height(height-80); - //$('#eventtable').height(height-100); }; /* get region and regionID of a location */ @@ -89,16 +77,26 @@ var eventTable = {}; var eventDetails = {}; var stationTable = {}; var config = { + ajax: { + timeout: 150000, // 15 seconds + eventURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query', + stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query', + nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php', + // nominatimURL: '//nominatim.openstreetmap.org/reverse', + }, event: { evaluationBlacklist: ['automatic', 'preliminary'], markerOpacity: 0.3, minMag: 1.2, + minMagDelta: 0.1, typeWhitelist: ['earthquake', 'induced or triggered event'], }, map: { zoomDefault: 9, zoomFocus: 12, centerDefault: [51.85, 7.0], + timespan: 180, + latlngDelta: 0.1, }, station: { markerOpacity: 0.5, @@ -110,15 +108,16 @@ var config = { **********************************************************************/ $(document).ready(function() { // AJAX setup - $.ajaxSetup({timeout: 15000}); // 15 seconds + $.ajaxSetup({timeout: config['ajax']['timeout']}); + // adjust height of infocontainer setInfoHeight(); + // create tabs var tabOptions = { active: 0, disabled: [2, 3], }; $('#tabs').tabs(tabOptions); - // $('.ui-tabs-nav').sortable(); }); diff --git a/www/stations.js b/www/stations.js index f8c2109..25aa806 100644 --- a/www/stations.js +++ b/www/stations.js @@ -29,11 +29,9 @@ function loadStations(stime, etime) { var E = mapBounds.getEast(); var S = mapBounds.getSouth(); var W = mapBounds.getWest(); - var d = 0.1; - var url = "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query"; if ( !stime ) { var stime = new Date(); - stime.setDate(stime.getDate()-180); + stime.setDate(stime.getDate()-config['map']['timespan']); }; if ( !etime ) { var etime = new Date(); @@ -42,14 +40,14 @@ function loadStations(stime, etime) { var request_data = { endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), - minlat: S-d, - maxlat: N+d, - minlon: W-d, - maxlon: E+d, + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], }; $.ajax({ type: "GET", - url: url, + url: config['ajax']['stationURL'], dataType: "xml", data: request_data, success: function (xml) { From 6f2bfad0e5dee979eefa747e6939e67faa690939 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 6 May 2014 16:55:31 +0000 Subject: [PATCH 2/4] New functionality: loading event details. TODO: add phase information --- www/events.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/www/events.js b/www/events.js index cbe7c05..af76769 100644 --- a/www/events.js +++ b/www/events.js @@ -85,7 +85,6 @@ function ajaxLoadEvents(stime, etime) { var otime = $(this).find('origin > time > value').text(); var lng = $(this).find('origin > longitude > value').text(); var lat = $(this).find('origin > latitude > value').text(); - var mag = $(this).find('magnitude > mag > value').text(); var evaluationMode = $(this).find('evaluationMode').text(); var evaluationStatus = $(this).find('evaluationStatus').text(); var type = $(this).find('type').last().text(); @@ -107,7 +106,7 @@ function ajaxLoadEvents(stime, etime) { + ''+location+'Karte' + ''; row += '' - + 'not implemented'; + + 'Daten werden geladen ...'; var added = $('#eventstable tbody').append(row); added.find('.tablesorter-childRow td').hide(); $('#eventstable').find('td.utctime-date').each(function() { @@ -145,6 +144,60 @@ function ajaxLoadEvents(stime, etime) { }); }; +/* ajaxLoadEventInfo */ +function ajaxLoadEventInfo(id) { + var request_data = { + eventid: id, + includeArrivals: true, + }; + $.ajax({ + type: "GET", + url: config['ajax']['eventURL'], + data: request_data, + dataType: "xml", + success: function (xml) { + eventDetails[id] = true; + $(xml).find('event').each(function () { + var mag = $(this).find('magnitude > mag > value').text(); + var otime = $(this).find('origin > time > value').text(); + var lng = $(this).find('origin > longitude > value').text(); + var lng_err = $(this).find('origin > longitude > uncertainty').text(); + var lat = $(this).find('origin > latitude > value').text(); + var lat_err = $(this).find('origin > latitude > uncertainty').text(); + var depth = $(this).find('origin > depth > value').text(); + var depth_err = $(this).find('origin > depth > uncertainty').text(); + var rms = $(this).find('origin > quality > standardError').text(); + var gap = $(this).find('origin > quality > azimuthalGap').text(); + var phases_count = $(this).find('origin > quality > usedPhaseCount').text(); + var type = $(this).find('type').last().text(); + var row = "
"
+					+ sprintf("ID %32s\n", id)
+					+ sprintf("Type %30s\n\n", type)
+					+ "Origin\n"
+					+ sprintf("Magnitude %13.1f\n", Number(mag))
+					+ sprintf("Date %18s\n", otime.split('T')[0])
+					+ sprintf("Time %18s UTC\n", otime.split('T')[1].substring(0, 11))
+					+ sprintf("Latitude %14.4f °N +- %4.1f km\n",Number(lat), Number(lat_err))
+					+ sprintf("Longitude %13.4f °E +- %4.1f km\n", Number(lng), Number(lng_err))
+					+ sprintf("Depth %14.1f    km +- %4.1f km\n", Number(depth)/1000., Number(depth_err)/1000.)
+					+ sprintf("Residual RMS %7.1f    sec\n", Number(rms))
+					+ sprintf("Azimuthal gap %6.1f    °\n\n", Number(gap))
+					+ sprintf("%d Phase arrivals:\n", Number(phases_count))
+					+ "sta  net   dist azi  phase   time         res   wt  sta\n";
+				row = row + '
'; + $('#eventstable > tbody > tr.tablesorter-childRow > td[eventid='+id+']').html(row); + }); + }, + complete: function () { + console.log('Fetched details for event '+id); + }, + error: function( jqxhr, textStatus, error ) { + var err = textStatus + ", " + error; + console.log( "Request Failed: " + err ); + } + }); +}; + /* add row to table obsolete */ function addEventRow(id, props) { @@ -311,6 +364,10 @@ $(document).ready(function() { // show / hide event info $('#eventstable').delegate('.toggle', 'click' , function(){ + // load event details + var eventid = $(this).attr('eventid'); + ( eventDetails[eventid] ) ? null : ajaxLoadEventInfo(eventid); + // toggle visibility of selected row $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle('slow'); @@ -319,7 +376,7 @@ $(document).ready(function() { $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').addClass('selected-now'); $(this).closest('tbody').find('td.selected').each(function(){ if ( ! $(this).hasClass('selected-now') ) { - $(this).hide('slow'); + $(this).hide(); $(this).removeClass('selected'); }; }); From 7f3d188f9ef1cda0ab060fd7243b8955d0734aa3 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 7 May 2014 12:15:52 +0000 Subject: [PATCH 3/4] Add phase information for event details. TODO: sorting by P-arrival removed obsolete function addEventRow. --- www/events.js | 80 +++++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 54 deletions(-) diff --git a/www/events.js b/www/events.js index af76769..40169de 100644 --- a/www/events.js +++ b/www/events.js @@ -158,6 +158,7 @@ function ajaxLoadEventInfo(id) { success: function (xml) { eventDetails[id] = true; $(xml).find('event').each(function () { + var event = $(this); var mag = $(this).find('magnitude > mag > value').text(); var otime = $(this).find('origin > time > value').text(); var lng = $(this).find('origin > longitude > value').text(); @@ -170,26 +171,46 @@ function ajaxLoadEventInfo(id) { var gap = $(this).find('origin > quality > azimuthalGap').text(); var phases_count = $(this).find('origin > quality > usedPhaseCount').text(); var type = $(this).find('type').last().text(); + // setting up general event info var row = "
"
-					+ sprintf("ID %32s\n", id)
-					+ sprintf("Type %30s\n\n", type)
+					+ sprintf("ID %49s\n", id)
+					+ sprintf("Type %47s\n\n", type)
 					+ "Origin\n"
-					+ sprintf("Magnitude %13.1f\n", Number(mag))
 					+ sprintf("Date %18s\n", otime.split('T')[0])
 					+ sprintf("Time %18s UTC\n", otime.split('T')[1].substring(0, 11))
 					+ sprintf("Latitude %14.4f °N +- %4.1f km\n",Number(lat), Number(lat_err))
 					+ sprintf("Longitude %13.4f °E +- %4.1f km\n", Number(lng), Number(lng_err))
 					+ sprintf("Depth %14.1f    km +- %4.1f km\n", Number(depth)/1000., Number(depth_err)/1000.)
+					+ sprintf("Magnitude %10.1f\n", Number(mag))
 					+ sprintf("Residual RMS %7.1f    sec\n", Number(rms))
 					+ sprintf("Azimuthal gap %6.1f    °\n\n", Number(gap))
 					+ sprintf("%d Phase arrivals:\n", Number(phases_count))
-					+ "sta  net   dist azi  phase   time         res   wt  sta\n";
+					+ "sta  net  dist azi     phase time         res   wt\n";
+				// adding phase info (TODO sort by distance)
+				$(this).find('origin > arrival').each(function() {
+					var pickid = $(this).find('pickID').text();
+					var azi = $(this).find('azimuth').text();
+					var dist = $(this).find('distance').text();
+					var tres = $(this).find('timeResidual').text();
+					var phase = $(this).find('phase').text();
+					var tweight = $(this).find('timeWeight').text();
+					if ( Number(tweight) > 0.0 ) {
+						var waveformid = event.find('pick[publicID="'+pickid+'"] > waveformID');
+						var networkcode = waveformid.attr('networkCode');
+						var stationcode = waveformid.attr('stationCode');
+						var channel = waveformid.attr('channelCode').substring(2,2);
+						var phasemode = event.find('pick[publicID="'+pickid+'"] > evaluationMode').text().substring(0,1).toUpperCase();
+						var picktime = event.find('pick[publicID="'+pickid+'"] > time > value').text().split('T')[1].substring(0,11);
+						row = row
+							+ sprintf('%-4s %2s  %5.1f %5.1f %3s %1s %13s %5.1f %5.2f\n', stationcode, networkcode, Number(dist), Number(azi), phase, phasemode, picktime, Number(tres), Number(tweight));
+					};
+				});
 				row = row + '
'; $('#eventstable > tbody > tr.tablesorter-childRow > td[eventid='+id+']').html(row); }); }, complete: function () { - console.log('Fetched details for event '+id); + null; }, error: function( jqxhr, textStatus, error ) { var err = textStatus + ", " + error; @@ -198,55 +219,6 @@ function ajaxLoadEventInfo(id) { }); }; -/* add row to table - obsolete */ -function addEventRow(id, props) { - $('#eventstable').tablesorter({ - sortList: "[[0,0], [1,1]], [2,1]", - resort: true, - showProcessing: true, - pager_size: 35 - }); - var html = '' - + ''+props.date+'T'+props.time.split('.')[0]+'Z' - + ''+props.date+'T'+props.time.split('.')[0]+'Z' - + ''+props.mag+'' - + ''+props.location+'Karte' - + '' - + '' - + '' - + "
ID                     "+id+"\n\n"
-		+ "Origin\n"
-		+ "Date                   "+props.date+"\n"
-		+ "Time                   "+props.time+"\n"
-		+ "Latitude                "+props.lat+" deg  +/-    "+props.lat_err+" km\n"
-		+ "Longitude                "+props.lon+" deg  +/-    "+props.lon_err+" km\n"
-		+ "Depth                       "+props.depth+" km   +/-    "+props.depth_err+" km\n"
-		+ "Residual RMS             "+props.rms+" s\n"
-		+ "Azimuthal gap             "+props.gap+" deg\n\n"
-		+ props.no_phases + " Phase arrivals:\n"
-		+ "sta  net   dist azi  phase   time         res     wt  sta\n";
-	for ( i = 0 ; i < props.no_phases ; i++ ) {
-		html +=  props.phases[i];
-		( i < props.no_phases -1 ) ? html += "\n" : null ;
-	};
-	html += "
\n"; - var added = $('#eventstable tbody').append(html); - added.find('.tablesorter-childRow td').hide(); - $('#eventstable').find('td.utctime-date').each(function() { - $.localtime.formatObject($(this), "dd. MM. yyyy"); - $(this).removeClass('utctime-date'); - $(this).addClass('localtime-date'); - }); - $('#eventstable').find('td.utctime-time').each(function() { - $.localtime.formatObject($(this), "HH:mm"); - $(this).removeClass('utctime-time'); - $(this).addClass('localtime-time'); - }); - // force resorting - $("#eventstable").trigger("update", [true]); -}; - /* toggles visibility of filtered markers * only events in the event list are shown */ function toggleFilteredMarkers() { From 02de11240581475491deab14d9152b8ad47debf6 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 7 May 2014 12:30:27 +0000 Subject: [PATCH 4/4] Blacklist rejected events. --- www/misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/misc.js b/www/misc.js index ef40af4..621ea11 100644 --- a/www/misc.js +++ b/www/misc.js @@ -85,7 +85,7 @@ var config = { // nominatimURL: '//nominatim.openstreetmap.org/reverse', }, event: { - evaluationBlacklist: ['automatic', 'preliminary'], + evaluationBlacklist: ['automatic', 'preliminary', 'rejected'], markerOpacity: 0.3, minMag: 1.2, minMagDelta: 0.1,