Category: on the moon

Distance to Point, Great Cricle Distance, Cosine Theorem, Haversine formula

comments Comments Off on Distance to Point, Great Cricle Distance, Cosine Theorem, Haversine formula
By , March 21, 2012 11:07 PM

Great Circle Distance Calculation

Finding locations nearby with MySQL

To find locations in our markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on Movable Type’s site.

Here’s the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) – radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;


SELECT ((ACOS(SIN($lat * PI() / 180) * SIN(`lat` * PI() / 180) + COS($lat * PI() / 180) * COS(`lat` * PI() / 180) * COS(($lon – `lon`) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance FROM `members` HAVING distance<=’10′ ORDER BY distance ASC


Necessary reading for Great Circle Distance Calculations


comments Comments Off on DELETE QUERY WITH 2 TABLES
By , February 8, 2012 10:57 PM



DELETE calllog
FROM calllog
JOIN locum ON calllog.LocumID = locum.LocumID
WHERE locum.LastName = “ANAME”

Moon pics

comments Comments Off on Moon pics
By , July 23, 2011 4:42 PM

Hi see pics




MYSQL Tuning and Optimizing of my.ini or my.cnf

comments Comments Off on MYSQL Tuning and Optimizing of my.ini or my.cnf
By , February 25, 2011 8:35 PM

One of the factors with the biggest impact on database performance is not the MySQL settings, but your queries! Make sure you have optimized all your queries first, and have created the right indexes on your tables for MySQL to use.

When tuning MySQL, the two most important variables to configure are key_buffer_size and table_cache. You should first feel confident that you have these set appropriately before trying to optimize any other variables. Ideally, key_buffer_size will be large enough to contain all the indexes (i.e. at least the total size of all .MYI files on the server) of your MyISAM tables.

1. query_cache_size:
* MySQL provides one feature that can prove very handy – a query cache. In a situation where the database has to repeatedly run the same queries on the same data set, returning the same results each time, MySQL can cache the result set, avoiding the overhead of running through the data over and over and is extremely helpful on busy servers.
2. key_buffer_size:
* The value of key_buffer_size is the size of the buffer used with indexes. The larger the buffer, the faster the SQL command will finish and a result will be returned. The rule-of-thumb is to set the key_buffer_size to at least a quarter, but no more than half, of the total amount of memory on the server. Ideally, it will be large enough to contain all the indexes (the total size of all .MYI files on the server).
* A simple way to check the actual performance of the buffer is to examine four additional variables: key_read_requests, key_reads, key_write_requests, and key_writes.
* If you divide the value of key_read by the value of key_reads_requests, the result should be less than 0.01. Also, if you divide the value of key_write by the value of key_writes_requests, the result should be less than 1.
3. table_cache:
* The default is 64. Each time MySQL accesses a table, it places it in the cache. If the system accesses many tables, it is faster to have these in the cache. MySQL, being multi-threaded, may be running many queries on the table at one time, and each of these will open a table. Examine the value of open_tables at peak times. If you find it stays at the same value as your table_cache value, and then the number of opened_tables starts rapidly increasing, you should increase the table_cache if you have enough memory.
4. sort_buffer:
* The sort_buffer is very useful for speeding up myisamchk operations (which is why it is set much higher for that purpose in the default configuration files), but it can also be useful everyday when performing large numbers of sorts.
5. read_rnd_buffer_size:
* The read_rnd_buffer_size is used after a sort, when reading rows in sorted order. If you use many queries with ORDER BY, upping this can improve performance. Remember that, unlike key_buffer_size and table_cache, this buffer is allocated for each thread. This variable was renamed from record_rnd_buffer in MySQL 4.0.3. It defaults to the same size as the read_buffer_size. A rule-of-thumb is to allocate 1KB for each 1MB of memory on the server, for example 1MB on a machine with 1GB memory.
6. thread_cache:
* If you have a busy server that’s getting a lot of quick connections, set your thread cache high enough that the Threads_created value in SHOW STATUS stops increasing. This should take some of the load off of the CPU.
7. tmp_table_size:
* “Created_tmp_disk_tables” are the number of implicit temporary tables on disk created while executing statements and “created_tmp_tables” are memory-based. Obviously it is bad if you have to go to disk instead of memory all the time.

Notes for the future (i.e InnoDB):
If you use InnoDB, it’s buffer pool is controlled by: innodb_buffer_pool_size (this cache also holds row level data). This is the equivalent of key_buffer_size for MyISAM key buffers.
This variable stores the internal data structure. Make sure it is big enough to store data about all your InnoDB tables (you will see warnings in the error log if the server is using OS memory instead).
Since MySQL 4.1.1, the buffer block size is available with the key_cache_block_size server variable. Default 1024.

then test your setup on to check your max memory size

conditions and temperature on the moon

comments Comments Off on conditions and temperature on the moon
By , September 7, 2009 10:08 AM

Maria (dark areas) and Terrae (light areas)

Full Moon from Northern Hemisphere

Full Moon from Northern Hemisphere

You will notice when looking at the moon’s surface dark and light areas.
The dark areas are called maria. There are several prominent maria.

  • Mare Tranquilitatis (Sea of Tranquility): where the first astronauts landed
  • Mare Imbrium (Sea of Showers): the largest mare (700 miles or 1100 kilometers in diameter)
  • Mare Serenitatis (Sea of Serenity)
  • Mare Nubium (Sea of Clouds)
  • Mare Nectaris (Sea of Nectar)
  • Oceanus Procellarum (Ocean of Storms)

The remainder of the lunar surface consists of the bright hilly areas called terrae.
These highlands are rough, mountainous, cratered regions.

The Apollo astronauts observed that the highlands are generally about 4 to 5 km (2.5 to 3 miles) above the average lunar surface elevation, while the maria are low-lying plains about 2 to 3 km (1.2 to 1.8 miles) below average elevation.

The Moon makes a complete orbit around the Earth every 27.3 days (the orbital period), and the periodic variations in the geometry of the Earth–Moon–Sun system are responsible for the phases of the moon, which repeat every 29.5 days (the synodic period).

Sides of the Moon

Locked Lunar Phase with earth

Locked Lunar Phase with earth

The Moon is in synchronous rotation, which means it rotates about its axis in about the same time it takes to orbit the Earth. This results in it keeping nearly the same face turned towards the Earth at all times. The Moon used to rotate at a faster rate, but early in its history, its rotation slowed and became locked in this orientation as a result of frictional effects associated with tidal deformations caused by the Earth.

The side of the Moon that faces Earth is called the near side, and the opposite side the far side. The far side is often inaccurately called the “dark side,” but in fact, it is illuminated exactly as often as the near side: once per lunar day, during the new moon phase we observe on Earth when the near side is dark. The far side of the Moon was first photographed by the Soviet probe Luna 3 in 1959. One distinguishing feature of the far side is its almost complete lack of maria.

Gravity of the Moon and Mass Concentration

Mass concentration or mascon is a region of a planet or moon’s crust that contains a large positive gravitational anomaly.
In general, the word “mascon” can be used as a noun to describe an excess distribution of mass on or beneath the surface of a planet (with respect to some suitable average), such as Hawaii. However, this term is most often used as an adjective to describe a geologic structure that has a positive gravitational anomaly, such as the “mascon basins” on the Moon.

Type examples of mascon basins on the Moon are the Imbrium, Serenitatis, Crisium and Orientale impact basins, all of which possess prominent topographic lows and positive gravitational anomalies. Examples of mascon basins on Mars include the Argyre, Isidis, and Utopia basins. Theoretical considerations imply that a topographic low in isostatic equilibrium would exhibit a slight negative gravitational anomaly. Thus, the positive gravitational anomalies associated with these impact basins indicate that some form of positive density anomaly must exist within the crust or upper mantle that is currently supported by the lithosphere. One possibility is that these anomalies are due to dense mare basaltic lavas, which might reach up to 6 kilometers in thickness for the Moon. However, while these lavas certainly contribute to the observed gravitational anomaly, uplift of the crust-mantle interface is also required to account for its magnitude. Indeed, some mascon basins on the Moon do not appear to be associated with any signs of volcanic activity, suggesting that the mantle uplift might even be super-isostatic (that is, uplifted above its isostatic position). It should be noted that the huge expanse of mare basaltic volcanism associated with Oceanus Procellarum does not possess a positive gravitational anomaly.

The lunar mascons alter the local gravity in certain regions sufficiently that low and uncorrected satellite orbits around the Moon are unstable on a timescale of months or years. This acts to distort successive orbits, causing the satellite to ultimately impact the surface. The lunar mascons were discovered by Paul M Muller and William Sjogren of the NASA Jet Propulsion Laboratory (JPL) in 1968[1] from analysis of the highly precise navigation data from the unmanned pre-Apollo Lunar Orbiter spacecraft. At that time, one of NASA’s highest priority “tiger team” projects was to explain why the Lunar Orbiter spacecraft being used to test the accuracy of Project Apollo navigation were experiencing errors in predicted position of ten times the mission specification (2 kilometers instead of 200 meters). This meant that the predicted landing areas were 100 times as large as those being carefully defined for reasons of safety. Lunar orbital effects resulting from strong gravitational perturbations were ultimately revealed as the cause. William Wollenhaupt and Emil Schiesser of the NASA Manned Spacecraft Center in Houston then worked out the “fix” that was first applied to Apollo 12 and permitted its landing within 300 meters of the target, the previously-landed Surveyor 3 spacecraft.

Diameter    3476 km, (0.27 x Earth’s)
Average Distance from Earth    384400 km
Temperature    Day:123°C Night: -233°C
Atmosphere    minimal – none
Magnetism weak (probably no significant iron core)
Time to orbit Earth    27.322 days
Time to spin once    27.322 days
Gravity    1/6 (0.16) of Earth’s

Thomas Challenger Thomas Challenger