Skip to content

Instantly share code, notes, and snippets.

@arthurpochart
Created September 28, 2020 14:50
Show Gist options
  • Save arthurpochart/befb13cb46c30354ebe4c41a1820b951 to your computer and use it in GitHub Desktop.
Save arthurpochart/befb13cb46c30354ebe4c41a1820b951 to your computer and use it in GitHub Desktop.
Approfondisemment Physique
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/appPhysique.iml" filepath="$PROJECT_DIR$/.idea/appPhysique.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="945a700d-8868-473a-82b9-cb4bda36f653" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
<option value="HTML File" />
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="JupyterTrust" id="46fea8ca-3a21-4822-a112-889710979a1b" />
<component name="ProjectId" id="1hHCzCSsueqdqRolMPgepDVKNZD" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
</component>
<component name="RunManager" selected="Python.Marees">
<configuration name="Marees" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="appPhysique" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/Marees.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="fonctions" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="appPhysique" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/fonctions.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="setup" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="appPhysique" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/setup.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="appPhysique" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="tets" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="appPhysique" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tets.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.Marees" />
<item itemvalue="Python.test" />
<item itemvalue="Python.fonctions" />
<item itemvalue="Python.setup" />
<item itemvalue="Python.tets" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="false" />
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="945a700d-8868-473a-82b9-cb4bda36f653" name="Default Changelist" comment="" />
<created>1599658890596</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1599658890596</updated>
<workItem from="1599918609952" duration="9045000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="WindowStateProjectService">
<state x="427" y="238" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1599816093637">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state x="427" y="238" key="#com.intellij.fileTypes.FileTypeChooser/[email protected]" timestamp="1599816093637" />
<state width="1326" height="260" key="GridCell.Tab.0.bottom" timestamp="1600094891256">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1326" height="260" key="GridCell.Tab.0.bottom/[email protected]" timestamp="1600094891256" />
<state width="1326" height="260" key="GridCell.Tab.0.center" timestamp="1600094891256">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1326" height="260" key="GridCell.Tab.0.center/[email protected]" timestamp="1600094891256" />
<state width="1326" height="260" key="GridCell.Tab.0.left" timestamp="1600094891256">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1326" height="260" key="GridCell.Tab.0.left/[email protected]" timestamp="1600094891256" />
<state width="1326" height="260" key="GridCell.Tab.0.right" timestamp="1600094891256">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1326" height="260" key="GridCell.Tab.0.right/[email protected]" timestamp="1600094891256" />
<state width="1227" height="278" key="GridCell.Tab.1.bottom" timestamp="1599688218338">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1227" height="278" key="GridCell.Tab.1.bottom/[email protected]" timestamp="1599688218338" />
<state width="1227" height="278" key="GridCell.Tab.1.center" timestamp="1599688218338">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1227" height="278" key="GridCell.Tab.1.center/[email protected]" timestamp="1599688218338" />
<state width="1227" height="278" key="GridCell.Tab.1.left" timestamp="1599688218338">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1227" height="278" key="GridCell.Tab.1.left/[email protected]" timestamp="1599688218338" />
<state width="1227" height="278" key="GridCell.Tab.1.right" timestamp="1599688218338">
<screen x="0" y="0" width="1368" height="872" />
</state>
<state width="1227" height="278" key="GridCell.Tab.1.right/[email protected]" timestamp="1599688218338" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/appPhysique$Marees.coverage" NAME="Marees Coverage Results" MODIFIED="1600095802096" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Map</title>
<script src="https://maps.google.com/maps/api/js?key=AIzaSyCvOQ_EW1L5rgNBi9puWqochACVK155b0M&v=3&sensor=false" type="text/javascript"></script>
<script type="text/javascript"
src="RTVMapType.js"></script>
<script type="text/javascript">
/**
* Initialize the Google map.
*/
function initialize() {
/**
* boiler-plate Google Maps code.
*/
var mapOptions = {
center: new google.maps.LatLng(38.0, -98.0),
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById("map_canvas"), mapOptions
);
/**
* Adding HFRADAR-derived surface currents to the map
*/
var rtv = new RTVMapType(map);
map.overlayMapTypes.push(rtv);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width: 500px; height: 300px;"></div>
</body>
</html>
import time
import datetime
def unixconv(date_0):
t = f"{date_0}"
timestamp = time.mktime(datetime.datetime.strptime(date_0, "%d/%m/%Y").timetuple())
return timestamp
import requests
import arrow
from terminaltables import AsciiTable
api_key = '5fa27ba6-f2a2-11ea-b18b-0242ac130002-5fa27c5a-f2a2-11ea-b18b-0242'
print("Bienvenue,veuillez rentrer votre position:")
print("Latitude")
lat = input()
print("Longitude")
lon = input()
#print("Que voulez vous consulter?")
#print("1: Marees 2: Vent")
#ans = input()
print("Date (DD/MM/YYYY): ")
date_0 = input()
date_1 = f"{str(int(date_0[0:2]) + 1)}/{date_0[3:5]}/{date_0[6:10]}"
print(date_1)
start = arrow.now().floor('day')
end = arrow.now().shift(days=1).floor('day')
response = requests.get(
'https://api.stormglass.io/v2/tide/sea-level/point',
params={
'lat': lat,
'lng': lon,
'start': start.to('UTC').timestamp, # Convert to UTC timestamp
'end': end.to('UTC').timestamp, # Convert to UTC timestam
},
headers={
'Authorization': '5fa27ba6-f2a2-11ea-b18b-0242ac130002-5fa27c5a-f2a2-11ea-b18b-0242ac130002'
}
)
json_data = response.json()
print(json_data)
sg0 = json_data['data'][0]['sg']
sg1 = json_data['data'][1]['sg']
sg2 = json_data['data'][2]['sg']
sg3 = json_data['data'][3]['sg']
sg4 = json_data['data'][4]['sg']
sg5 = json_data['data'][5]['sg']
sg6 = json_data['data'][6]['sg']
sg7 = json_data['data'][7]['sg']
sg8 = json_data['data'][8]['sg']
sg9 = json_data['data'][9]['sg']
sg10 = json_data['data'][10]['sg']
sg11 = json_data['data'][11]['sg']
sg12 = json_data['data'][12]['sg']
sg13 = json_data['data'][13]['sg']
sg14 = json_data['data'][14]['sg']
sg15 = json_data['data'][15]['sg']
sg16 = json_data['data'][16]['sg']
sg17 = json_data['data'][17]['sg']
sg18 = json_data['data'][18]['sg']
sg19 = json_data['data'][19]['sg']
sg20 = json_data['data'][20]['sg']
sg21 = json_data['data'][21]['sg']
sg22 = json_data['data'][22]['sg']
sg23 = json_data['data'][23]['sg']
sg24 = json_data['data'][24]['sg']
station = json_data['meta']['station']['name']
dist = json_data['meta']['station']['distance']
data = []
data.append([date_0])
data.append(['00:00',sg0,'12:00',sg12])
data.append(['01:00',sg1,'13:00',sg13])
data.append(['02:00',sg2,'14:00',sg14])
data.append(['03:00',sg3,'15:00',sg15])
data.append(['04:00',sg4,'16:00',sg16])
data.append(['05:00',sg5,'17:00',sg17])
data.append(['06:00',sg6,'18:00',sg18])
data.append(['07:00',sg7,'19:00',sg19])
data.append(['08:00',sg8,'20:00',sg20])
data.append(['09:00',sg9,'21:00',sg21])
data.append(['10:00',sg10,'22:00',sg22])
data.append(['11:00',sg11,'23:00',sg23])
data.append(["Distance",dist])
table = AsciiTable(data, title=station)
print(table.table)
/**
* Provides remote access to rendered RTV vector tiles.
*
* @file RTVMapType.js
* @date 2017-08-07 12:40 PDT
* @author Paul Reuter/Joseph Chen
* @version 4.0.1
*
* @modifications
* 1.0.0 - 2008-01-30 - Initially conceived, prototyped.
* 2.0.0 - 2009-07-25 - Public API redesign
* 2.0.1 - 2009-08-07 - Modifications: Changed some initialization inheritance
* 2.0.2 - 2009-11-09 - Modify: Changed path on sandbar.
* 2.0.3 - 2009-11-09 - Undo path change on sandbar (CeNCOOS legacy).
* 2.0.4 - 2009-12-14 - Changed tile server, tile status server.
* 2.0.4 - 2010-02-23 - BugFix: setHourly, setAveraged default values.
* 2.0.4 - 2010-02-23 - Modified callback handler: dynamic func generation.
* 2.0.4 - 2010-02-25 - BugFix: finAvail shouldn't set time if user did.
* 2.0.5 - 2010-04-14 - Add: getStation/Network[Count] methods.
* 2.0.6 - 2010-10-19 - Add: getLatestTimestampAtLatLng(latlng)
* 3.0.0 - 2012-07-24 - Major revision for Google Maps v3 API.
* 3.0.1 - 2012-11-29 - New object name, same methods, same intention.
* 3.0.2 - 2013-08-23 - BugFix via John Maurer: getTileUrl dateline wrap.
* 3.0.3 - 2014-01-06 - Modify: getTileUrl to support multiple countries.
* 3.0.4 - 2014-09-12 - Modify: hfrnet became hfrnet-old for hardware upgrade
* 3.0.5 - 2014-10-10 - Modify: hfrnet-old became hfrnet
* 3.0.6 - 2015-01-29 - Add: getEarliestTimestamp
* 3.0.7 - 2015-09-28 - BugFix: Google Maps changed something.
* 3.0.8 - 2015-09-28 - BugFix: improve initialization.
* 4.0.0 - 2017-06-02 - Added support for global
* 4.0.1 - 2017-08-07 - Added support for https
*/
/**
* opts: google.maps.ImageMapTypeOptions
* alt, getTileUrl, maxZoom, minZoom, name, opacity, tielSize
*/
function RTVMapType(map,opts) {
opts = opts || {};
this.minZoom = opts.minZoom || 0;
this.maxZoom = opts.maxZoom || 12;
this.opacity = opts.opacity || 0.8;
this.tileSize = opts.tileSize || new google.maps.Size(256,256);
this.map = map;
this.pfx = opts.pfx || 'a';
this.tld = opts.tld || 'us';
this.extension = opts.extension || 'png';
this.res = opts.res || 6000;
this.range = opts.range || [0,50];
this.country = opts.country || 'us';
this.ts = null;
this.scheme = opts.scheme || 4;
this.version = '4.0.0';
this.self = this;
google.maps.event.addListener(this,'statechange',this.refresh);
google.maps.event.addListener(this,"network_loaded",this.m_synchronizedLoad);
google.maps.event.addListener(this,"latest_loaded",this.m_synchronizedLoad);
// Stuff for tracking most recent layers.
this.m_upperTimestamps = [];
this.m_networkStatus = null;
this.m_initializeAvailability();
this.m_initializeNetworkStatus();
}; // END: constructor RTVMapType
RTVMapType.prototype = new google.maps.MVCObject();
/**
* getTileUrl is used by getTile, but is no longer required by interface.
*/
RTVMapType.prototype.getTileUrl = function(t,z) {
if( z < this.minZoom || z > this.maxZoom || !this.ts ) {
return '';
}
var d = new Date(this.ts*1000);
var yyyy_mm = d.gmstrftime("%Y-%m");
var yyyymmdd_hh00 = d.gmstrftime("%Y%m%d_%H00");
var zz = (z<10) ? '0'+z : z;
/**
* BugFix Work-around:
*
* t.x exceeds allowed tile index in certain circumstances,
* when date-line is present in the viewport.
*
* @author John Maurer
* @since 2013-08-23
*/
var nx = Math.pow(2,z);
//return 'http://mosaic.ucsd.edu/tiles/rtv/'+this.tld +'/'+
return '//mosaic.ucsd.edu/tiles/rtv/'+this.tld +'/'+
this.pfx+'/'+this.res+'/'+yyyy_mm+'/'+yyyymmdd_hh00+
'/'+zz+'/z'+z+'y'+t.y+'x'+((nx+t.x)%nx)+'.'+
this.extension+'?rng='+this.range.join(',') +
'&scheme='+this.scheme;
}; // END: function getTileUrl(t,z)
/**
* Since Google Maps v3.22, we're forced to inherit from MVCObject
* and provide getTile.
* Since ImageMapType initializes from a non-mutable MapType,
* we actually have to build the whole DOM element.
* We had to reverse engineer ImageMapType's node to optimize performance.
*/
RTVMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
var url = this.getTileUrl(coord, zoom);
var div = ownerDocument.createElement('div');
div.innerHTML = '<img src="//maps.gstatic.com/mapfiles/transparent.png" draggable="false">';
div.style['-moz-user-select'] = 'none';
if( url ) {
div.style.background = 'url('+url+')';
}
div.style.margin = '0';
div.style.padding = '0';
div.style.border = '0 none';
div.style.opacity = this.opacity;
div.style.width = this.tileSize.width + 'px';
div.style.height = this.tileSize.height + 'px';
return div;
};
RTVMapType.keys = function(arr) {
var ks = [];
for( var k in arr ) {
ks.push(k);
}
return ks;
};
RTVMapType.values = function(arr) {
var vs = [];
for( var k in arr ) {
vs.push(arr[k]);
}
return vs;
};
RTVMapType.array_map = function(keys,vals) {
var amap = {};
while( keys.length > 0 && vals.length > 0 ) {
amap[keys.shift()] = vals.shift();
}
return amap;
};
RTVMapType.inArray = function(item,arr) {
for(var k in arr) {
if( arr[k] == item ) {
return k;
}
}
return -1;
};
RTVMapType.prototype.getStation = function(callsign,netname) {
if( this.haveNetworkStatus() ) {
var use_netname = (typeof(netname)!="undefined");
var hdr = RTVMapType.keys( this.m_networkStatus.meta.keys.stations );
var sta_ix = RTVMapType.inArray( 'sta', hdr );
var net_ix = RTVMapType.inArray( 'net', hdr );
if( sta_ix < 0 || net_ix < 0 ) {
return false;
}
for(var i=0,n=this.m_networkStatus.data.stations.length; i<n; i++) {
var obj = this.m_networkStatus.data.stations[i];
if( obj[sta_ix] == callsign ) {
if( use_netname ) {
if( obj[net_ix] == netname ) {
return RTVMapType.array_map(hdr,obj);
}
} else {
return RTVMapType.array_map(hdr,obj);
}
}
}
}
return false;
}; // END: function getStation(callsign,network?)
RTVMapType.prototype.getStations = function() {
if( this.haveNetworkStatus() ) {
var stas = [];
var hdr = RTVMapType.keys( this.m_networkStatus.meta.keys.stations );
var sta_ix = RTVMapType.inArray( 'sta', hdr );
if( sta_ix < 0 ) {
return false;
}
for(var i=0,n=this.m_networkStatus.data.stations.length; i<n; i++) {
stas.push( this.m_networkStatus.data.stations[i][sta_ix] );
}
return stas;
}
return false;
}; // END: function getStations()
RTVMapType.prototype.getStationCount = function() {
if( this.haveNetworkStatus() ) {
return this.m_networkStatus.data.status.nSites;
}
return false;
}; // END: function getStationCount()
RTVMapType.prototype.getNetwork = function(netname) {
if( this.haveNetworkStatus() ) {
var hdr = RTVMapType.keys( this.m_networkStatus.meta.keys.stations );
var net_ix = RTVMapType.inArray( 'net', hdr );
if( net_ix < 0 ) {
return false;
}
for(var i=0,n=this.m_networkStatus.data.networks.length; i<n; i++) {
var obj = this.m_networkStatus.data.networks[i];
if( obj[net_ix] == netname ) {
return obj;
}
}
}
return false;
}; // END: function getNetwork(netname)
RTVMapType.prototype.getNetworks = function() {
if( this.haveNetworkStatus() ) {
var nets = [];
var hdr = RTVMapType.keys( this.m_networkStatus.meta.keys.networks );
var net_ix = RTVMapType.inArray( 'net', hdr );
if( net_ix < 0 ) {
return false;
}
for(var i=0,n=this.m_networkStatus.data.networks.length; i<n; i++) {
nets.push( this.m_networkStatus.data.networks[i][net_ix] );
}
return nets;
}
return false;
}; // END: function getNetworks()
RTVMapType.prototype.getNetworkCount = function() {
if( this.haveNetworkStatus() ) {
return this.m_networkStatus.data.status.nNets;
}
return false;
}; // END: function getNetworkCount()
RTVMapType.prototype.getNetworkUpdateTime = function() {
if( this.haveNetworkStatus() ) {
return this.m_networkStatus.data.status.latest;
}
return false;
}; // END: function getNetworkUpdateTime()
RTVMapType.prototype.getLatestTimestamp = function() {
var timerec = this.m_getSelectedTimestampRecord();
if( !timerec ) {
// not loaded yet, listen for RTVMapType 'load' event.
return false;
}
return Number(timerec["latest"]);
};
RTVMapType.prototype.getEarliestTimestamp = function() {
var timerec = this.m_getSelectedTimestampRecord();
if( !timerec ) {
// not loaded yet, listen for RTVMapType 'load' event.
return false;
}
return Number(timerec["earliest"]);
};
RTVMapType.prototype.setLatestTimestamp = function() {
var ts = this.getLatestTimestamp();
return (ts===false) ? false : this.setTimestamp(ts);
};
RTVMapType.prototype.setLatestTimestampAtLatLng = function(latlng,cb) {
var that = this;
this.getLatestTimestampAtLatLng(latlng,function(ts,obj) {
var ret = (ts>0) ? that.setTimestamp(ts) : false;
// Call user function if present.
if( typeof(cb) !== "undefined" ) {
cb.call(that,ts,obj);
}
return ret;
});
};
RTVMapType.prototype.getLatestTimestampAtLatLng = function(latlng,func) {
if( !latlng || !latlng.constructor ) {
return false;
}
var qstring = 'll='+latlng.toUrlValue() +
'&res=' + this.getResolution() +
'&pfx=' + this.getPrefix();
// Generate unique function name and define it.
var fname = '__ltll_'+this.pfx+'_'+this.res+'_'+this.ts+'_'+
(new Date()).getTime();
var fbody = ' google.maps.event.trigger(window,"e_'+fname+'",obj); '+
' google.maps.event.clearListeners(window,"e_'+fname+'"); ';
window[fname] = new Function('obj', fbody);
var head = document.getElementsByTagName("head")[0];
var scriptTag = document.getElementById('dataScript_'+fname);
if(scriptTag) head.removeChild(scriptTag);
script = document.createElement('script');
//script.src = 'http://hfrnet.ucsd.edu/rtv/ll.php?'+qstring+'&callback='+fname;
script.src = '//hfrnet.ucsd.edu/rtv/ll.php?'+qstring+'&callback='+fname;
script.type = 'text/javascript';
script.id = 'dataScript_'+fname;
head.appendChild(script);
// Listen for event triggered from unique function.
var that = this;
google.maps.event.addListener(window,'e_'+fname,function(obj) {
// Call user function.
if( obj.error ) {
func.call(that,-1,obj);
} else {
func.call(that,Number(obj.latest),obj);
}
});
return true;
};
RTVMapType.prototype.getVectorData = function(latlng,func) {
if( !latlng || !latlng.constructor ) {
return false;
}
var qstring = 'lat='+latlng.lat()+'&lon='+latlng.lng()+
'&time='+this.getTimestamp()+'&res='+this.getResolution()+
'&pfx='+this.getPrefix();
// Generate unique function name and define it.
var fname = '__vdata_'+this.pfx+'_'+this.res+'_'+this.ts+'_'+
(new Date()).getTime();
var fbody = ' google.maps.event.trigger(window,"e_'+fname+'",obj); '+
' google.maps.event.clearListeners(window,"e_'+fname+'"); ';
window[fname] = new Function('obj', fbody);
var head = document.getElementsByTagName("head")[0];
var scriptTag = document.getElementById('dataScript_'+fname);
if(scriptTag) head.removeChild(scriptTag);
// hfrnet for US, mosaic for global
var server;
var page; // country code
if( this.tld == 'us' ) {
server="hfrnet.ucsd.edu";
page="";
}
else {
server="mosaic.ucsd.edu";
page="p="+this.tld+"&";
}
script = document.createElement('script');
script.src = '//'+server+'/rtv/nn.php?'+page+qstring+'&callback='+fname;
script.type = 'text/javascript';
script.id = 'dataScript_'+fname;
head.appendChild(script);
// Listen for event triggered from unique function.
var that = this;
google.maps.event.addListener(window,'e_'+fname,function(obj) {
// Call user function.
func.call(that,obj);
});
return true;
};
RTVMapType.prototype.m_initializeNetworkStatus = function() {
// Generate unique function name and define it.
var fname = '__rtv_'+(new Date()).getTime();
var fbody = ' google.maps.event.trigger(window,"e_'+fname+'",obj); '+
' google.maps.event.clearListeners(window,"e_'+fname+'"); ';
window[fname] = new Function('obj', fbody);
var head = document.getElementsByTagName("head")[0];
var scriptTag = document.getElementById('networkScript_'+fname);
if(scriptTag) head.removeChild(scriptTag);
script = document.createElement('script');
//script.src = 'http://hfrnet.ucsd.edu/rtv/sm.php?callback='+fname;
script.src = '//hfrnet.ucsd.edu/rtv/sm.php?callback='+fname;
script.type = 'text/javascript';
script.id = 'networkScript_'+fname;
head.appendChild(script);
var that = this;
google.maps.event.addListener(window,'e_'+fname,function(obj) {
// Call user function.
that.m_networkStatus = obj;
google.maps.event.trigger(that,"network_loaded");
});
return true;
};
RTVMapType.prototype.m_initializeAvailability = function() {
// Generate unique function name and define it.
var fname = '__rtv_'+this.pfx+'_'+this.res+'_'+this.ts+'_'+
(new Date()).getTime();
var fbody = ' google.maps.event.trigger(window,"e_'+fname+'",obj); '+
' google.maps.event.clearListeners(window,"e_'+fname+'"); ';
window[fname] = new Function('obj', fbody);
var head = document.getElementsByTagName("head")[0];
var scriptTag = document.getElementById('loadScript_'+fname);
if(scriptTag) head.removeChild(scriptTag);
script = document.createElement('script');
//script.src = 'http://hfrnet.ucsd.edu/rtv/ts.php?callback='+fname;
script.src = '//hfrnet.ucsd.edu/rtv/ts.php?callback='+fname;
script.type = 'text/javascript';
script.id = 'loadScript_'+fname;
head.appendChild(script);
google.maps.event.bind(window,'e_'+fname,this,this.m_finalizeAvailability);
};
RTVMapType.prototype.m_finalizeAvailability = function(obj) {
this.m_upperTimestamps = obj;
var timerec = this.m_getSelectedTimestampRecord();
if( !timerec ) {
alert("Invalid configuration. The service may be down.");
return false;
}
// It's possible that the user changed the time before this returned.
// So only set timestamp if it hasn't been initialized.
if( this.ts == null || this.ts == 0 ) {
this.setTimestamp(Number(timerec["latest"]));
}
google.maps.event.trigger(this,'latest_loaded',Number(timerec["latest"]));
};
RTVMapType.prototype.haveTimestamps = function() {
return (this.m_upperTimestamps.length>0) ? true : false;
}
RTVMapType.prototype.haveNetworkStatus = function() {
return (this.m_networkStatus) ? true : false;
}
RTVMapType.prototype.m_synchronizedLoad = function() {
if( this.haveTimestamps() && this.haveNetworkStatus() ) {
google.maps.event.trigger(this,'load',this.getTimestamp());
}
};
RTVMapType.prototype.m_getSelectedTimestampRecord = function() {
for(var i=0,n=this.m_upperTimestamps.length; i<n; i++) {
if( this.m_upperTimestamps[i].resolution == this.res
&& this.m_upperTimestamps[i].prefix == this.pfx ) {
return this.m_upperTimestamps[i];
}
}
return null;
};
RTVMapType.prototype.setExtension = function(ext) {
if( this.extension != ext ) {
this.extension = ext;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getExtension = function() {
return this.extension;
};
RTVMapType.prototype.setOpacity = function(op) {
op = (op>1) ? op/100 : op;
if( this.opacity != op ) {
this.opacity = (op>1) ? op/100 : op;
google.maps.event.trigger(this,'statechange');
}
};
// GMap2 interface
RTVMapType.prototype.getOpacity = function() {
return this.opacity;
};
RTVMapType.prototype.setMinZoom = function(zoom) {
if( this.minZoom != zoom ) {
this.minZoom = zoom;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getMinZoom = function() {
return this.minZoom;
};
RTVMapType.prototype.setMaxZoom = function(zoom) {
if( this.maxZoom != zoom ) {
this.mazZoom = zoom;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getMaxZoom = function() {
return this.mazZoom;
};
RTVMapType.prototype.setZoomRange = function(z0,z1) {
if( this.minZoom != z0 || this.maxZoom != z1 ) {
this.minZoom = z0;
this.mazZoom = z1;
google.maps.event.trigger(this,'statechange');
}
};
// GMap2 interface
RTVMapType.prototype.minResolution = function() {
return this.minZoom;
}
// GMap2 interface
RTVMapType.prototype.maxResolution = function() {
return this.maxZoom;
}
// GMap2 interface
RTVMapType.prototype.getCopyright = function(gllb,zoom) {
if( !this.copyrights ) {
return 'CORDC';
}
return this.copyrights.getCopyrightNotice(gllb,zoom);
};
// GMap2 interface
RTVMapType.prototype.isPng = function() {
return (String(this.extension).toLowerCase()=="png");
};
RTVMapType.prototype.setColorRange = function(lo,hi) {
if( this.range[0] != lo || this.range[1] != hi ) {
this.range = [lo,hi];
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getColorRange = function() {
return this.range;
};
RTVMapType.prototype.setColorScheme = function(scheme) {
if( this.scheme != scheme ) {
this.scheme = scheme;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getColorScheme = function() {
return this.scheme;
};
RTVMapType.prototype.getColorbarUrl = function(w,h) {
w = w || 220;
h = h || 45;
var px = 8;
var py = 15;
h = Math.max(5,h-2*py);
w = Math.max(30,w-2*px);
return '//cordc.ucsd.edu/projects/mapping/maps/img/php/cb.php'+
'?range='+this.range.join(',')+'&scheme='+this.scheme+
'&width='+w+'&height='+h+'&padding='+py+','+px+
'&title='+escape('Current Strength (cm/s)')+
'&font_size=10&ticks=6';
};
RTVMapType.prototype.setPrefix = function(pfx) {
if( this.pfx != pfx ) {
this.pfx = pfx;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getPrefix = function() {
return this.pfx;
};
RTVMapType.prototype.setResolution = function(res) {
res = this.getResolutionMeters(res);
if( this.res != res ) {
this.res = res;
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getResolution = function() {
return this.res;
};
RTVMapType.prototype.getResolutionMeters = function(res) {
if( String(parseInt(res)) == String(res) ) {
return Number(res);
}
var pts = String(res).match(/^\s*(\d+)([^0-9]+)\s*$/);
if( pts[2].toLowerCase() == 'km' ) {
return Number(pts[1])*1000;
}
return Number(pts[1]);
};
RTVMapType.prototype.setAveraged = function(bAvg) {
var pfx = (typeof(bAvg)=='undefined' || bAvg) ? "a" : "h";
return this.setPrefix( pfx );
};
RTVMapType.prototype.setHourly = function(bHour) {
var pfx = (typeof(bHour)=='undefined' || bHour) ? "h" : "a";
return this.setPrefix( pfx );
};
RTVMapType.prototype.setTimestamp = function(ts) {
// If timestamp isn't specified, use yesterday as as start.
// The starting point is later initialized as the most recent available
// upon startup. This just provides extra fall-back.
if( typeof(ts) == "undefined" ) {
// default to -1 day
var d = new Date();
ts = Math.floor(d.getTime()/1000) - 86400;
ts -= ts%3600;
}
if( this.ts != ts && ts !== 0) {
this.ts = ts;
// console.log('timechange: '+ts);
google.maps.event.trigger(this,'timechange',ts);
google.maps.event.trigger(this,'statechange');
}
};
RTVMapType.prototype.getTimestamp = function() {
return this.ts;
};
RTVMapType.prototype.getVersion = function() {
return this.version;
};
RTVMapType.prototype.refresh = function() {
for(var i=0,n=this.map.overlayMapTypes.getLength(); i<n; i++) {
if( this.map.overlayMapTypes.getAt(i) == this ) {
obj = this.map.overlayMapTypes.removeAt(i);
this.map.overlayMapTypes.insertAt(i,obj);
break;
}
}
}; // END: function refresh()
/**
* Extra dependencies.
*/
/* other support functions -- thanks, ecmanaut! */
var strftime_funks = {
zeropad: function( n ){ return n>9 ? n : '0'+n; },
a: function(t) { return ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][t.getDay()] },
A: function(t) { return ['Sunday','Monday','Tuedsay','Wednesday','Thursday','Friday','Saturday'][t.getDay()] },
b: function(t) { return ['Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'][t.getMonth()] },
B: function(t) { return ['January','February','March','April','May','June', 'July','August',
'September','October','November','December'][t.getMonth()] },
c: function(t) { return t.toString() },
d: function(t) { return this.zeropad(t.getDate()) },
H: function(t) { return this.zeropad(t.getHours()) },
I: function(t) { return this.zeropad((t.getHours() + 12) % 12) },
m: function(t) { return this.zeropad(t.getMonth()+1) }, // month-1
M: function(t) { return this.zeropad(t.getMinutes()) },
p: function(t) { return this.H(t) < 12 ? 'AM' : 'PM'; },
S: function(t) { return this.zeropad(t.getSeconds()) },
w: function(t) { return t.getDay() }, // 0..6 == sun..sat
y: function(t) { return this.zeropad(this.Y(t) % 100); },
Y: function(t) { return t.getFullYear(); },
Z: function(t) {
tzo = t.getTimezoneOffset();
pfx = (tzo>0) ? "-" : "+";
return pfx+this.zeropad(Math.floor(tzo/60))+this.zeropad(t.getTimezoneOffset()%60);
},
'%': function(t) { return '%' }
};
var gmstrftime_funks = {
zeropad: function( n ){ return n>9 ? n : '0'+n; },
a: function(t) { return ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][t.getUTCDay()] },
A: function(t) { return ['Sunday','Monday','Tuedsay','Wednesday','Thursday','Friday','Saturday'][t.getUTCDay()] },
b: function(t) { return ['Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'][t.getUTCMonth()] },
B: function(t) { return ['January','February','March','April','May','June', 'July','August',
'September','October','November','December'][t.getUTCMonth()] },
c: function(t) { return t.toGMTString() },
d: function(t) { return this.zeropad(t.getUTCDate()) },
H: function(t) { return this.zeropad(t.getUTCHours()) },
I: function(t) { return this.zeropad((t.getUTCHours() + 12) % 12) },
m: function(t) { return this.zeropad(t.getUTCMonth()+1) }, // month-1
M: function(t) { return this.zeropad(t.getUTCMinutes()) },
p: function(t) { return this.H(t) < 12 ? 'AM' : 'PM'; },
S: function(t) { return this.zeropad(t.getSeconds()) },
w: function(t) { return t.getUTCDay() }, // 0..6 == sun..sat
y: function(t) { return this.zeropad(this.Y(t) % 100); },
Y: function(t) { return t.getUTCFullYear() },
Z: function(t) { return "UTC" },
'%': function(t) { return '%' }
};
Date.prototype.strftime = function (fmt) {
var t = this;
for (var s in strftime_funks) {
if (s.length == 1 )
fmt = fmt.replace('%' + s, strftime_funks[s](t));
}
return fmt;
};
Date.prototype.gmstrftime = function (fmt) {
var t = this;
for (var s in gmstrftime_funks) {
if (s.length == 1 )
fmt = fmt.replace('%' + s, gmstrftime_funks[s](t));
}
return fmt;
};
if ( typeof(TrimPath) != "undefined" ) {
TrimPath.parseTemplate_etc.modifierDef.strftime = function (t, fmt) {
return new Date(t).strftime(fmt);
}
}
if ( typeof(TrimPath) != "undefined" ) {
TrimPath.parseTemplate_etc.modifierDef.gmstrftime = function (t, fmt) {
return new Date(t).gmstrftime(fmt);
}
}
import time
import datetime
from fonctions import unixconv
print("Date (DD/MM/YYYY): ")
date_0 = input()
date_1 = f"{str(int(date_0[0:2]) + 1)}/{date_0[3:5]}/{date_0[6:10]}"
print(date_1)
start = datetime.datetime.utcfromtimestamp(unixconv(date_0))
end = datetime.datetime.utcfromtimestamp(unixconv(date_1))
print(start)
print(end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment