wolfram-mathematica

Convert Lat/Long to X/Y for Albers Projection on US Map Image

本小妞迷上赌 提交于 2019-12-04 09:59:01
I'm trying to use C# or Javascript to convert Lat/Longs into X/Y Coordinates to position divs with CSS (left, top) onto a background image of a US map. The standard map projection of the United States is an Albers Projection as seen below, but StackOverflow only has references for Lat/Long conversions that refer to basic Mercator projections. Map: http://en.wikipedia.org/wiki/File:Usa_counties_large.svg Map Size: 1460px width x 914px height Lat/Long Samples: LA: 34.0525, -118.2544 NY: 40.7582, -73.9679 DEN: 39.7512, -104.9975 Albers Projection Formula: http://en.wikipedia.org/wiki/Albers

ode integration in python versus mathematica results

天大地大妈咪最大 提交于 2019-12-04 09:51:23
Edit: So I found out that NDSolve for ODE is using Runge Kutta to solve the equations. How can I use the Runge Kutta method on my python code to solve the ODE I have below? From my post on text files with float entries , I was able to determine that python and mathematica immediately start diverging with a tolerance of 10 to the negative 6. End Edit For last few hours, I have been trying to figure out why my solutions in Mathematica and Python differ by 5000 something km . I am led to believe one program has a higher error tolerance when simulating over millions of seconds in flight time. My

chaos game for DNA sequences

一曲冷凌霜 提交于 2019-12-04 09:34:59
问题 I have tried the mathematica code for making the chaos game for DNA sequences posted in this address: http://facstaff.unca.edu/mcmcclur/blog/GeneCGR.html which is like this: genome = Import["c:\data\sequence.fasta", "Sequence"]; genome = StringReplace[ToString[genome], {"{" -> "", "}" -> ""}]; chars = StringCases[genome, "G" | "C" | "T" | "A"]; f[x_, "A"] := x/2; f[x_, "T"] := x/2 + {1/2, 0}; f[x_, "G"] := x/2 + {1/2, 1/2}; f[x_, "C"] := x/2 + {0, 1/2}; pts = FoldList[f, {0.5, 0.5}, chars];

How to decrease file size of exported plots while keeping labels sharp

亡梦爱人 提交于 2019-12-04 09:15:27
问题 When exporting rather complicated plots (especially ListDensityPlot ) as a PDF or EPS (for publication, for example), the resulting file size can be quite large. For example: data = Flatten[Table[{f0, f, Exp[-(f - f0)^2/25^2]}, {f0, 500, 700, 5}, {f, 300, 900}], 1]; plot=ListDensityPlot[data,PlotRange->{Automatic,Automatic,{0,1}},InterpolationOrder->0] This example data set is on the order of the size I typically work with. When I export using Export["C:\\test.pdf", plot] , it generates a PDF

Mathematica: set default value for argument to nonconstant?

浪子不回头ぞ 提交于 2019-12-04 09:09:16
Can I set the default value for a function argument to be something that's not constant? Example: tod := Mod[AbsoluteTime[], 86400] f[x_:tod] := x In the above, 'tod' changes every time I evaluate it, but "f[]" does not. "?f" yields: f[x_:42054.435657`11.376386798562935] := x showing the default value was hardcoded when I created the function. Is there a workaround here? It seems to work if the function holds its arguments: tod := Mod[AbsoluteTime[], 86400] SetAttributes[f, HoldAll]; f[x_: tod] := x In[23]:= f[] Out[23]= 47628.994048 In[24]:= f[] Out[24]= 47629.048193 Or you can use a

Importing Google Sketchup models in Mathematica

江枫思渺然 提交于 2019-12-04 09:01:31
问题 Google's Sketchup is a nice, simple 3D-object modeler. Moreover Google has an enormous warehouse of 3D objects so that you actually don't have to do much modeling yourself if you aren't particularly gifted in this area. Many of the 3D buildings in Google Earth are made with Sketchup. The capability to import Sketchup's SKP files in Mathematica would be very nice, but alas, it doesn't do that yet. The free version of Sketchup doesn't export to any other formats than the KMZ (Google Earth) and

Monitoring progress of a parallel computation in Mathematica

和自甴很熟 提交于 2019-12-04 08:59:19
问题 I'm building a large ParallelTable , and would like to maintain some sense of how the computation is going. For a non parallel table the following code does a great job: counter = 1; Timing[ Monitor[ Table[ counter++ , {n, 10^6}]; , ProgressIndicator[counter, {0, 10^6}] ] ] with the result {0.943512, Null} . For the parallel case, however, it's necessary to make the counter shared between the kernels: counter = 1; SetSharedVariable[counter]; Timing[ Monitor[ ParallelTable[ counter++ , {n, 10

Mathematica: How to apply function to a certain column of a table

早过忘川 提交于 2019-12-04 08:25:18
问题 I would like to apply a function to a specific column of a table. Say to the i-th column of a (m x n) table. Actually I just want to multiply all elements in that column with a scalar, but the application of a general function would be fine as well. It probably just needs some Map or MapAt command, maybe combined with a Transpose in order to apply to rows instead of columns - but I can't figure out the correct syntax for addressing an entire column (or row).. Any hints would be highly

Import from web - set user agent in Mathematica

浪尽此生 提交于 2019-12-04 08:23:12
问题 when I connect to my site with Mathermatica ( Import["mysite","Data"] ) and look at my Apache log I see: 99.XXX.XXX.XXX - - [22/May/2011:19:36:28 +0200] "GET / HTTP/1.1" 200 6268 "-" "Mathematica/8.0.1.0.0 PM/1.3.1" Could I set it to be something like this (when I connects with real browser): 99.XXX.XXX.XXX - - [22/May/2011:19:46:17 +0200] "GET /favicon.ico HTTP/1.1" 404 183 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24" 回答1:

Exposing Symbols to $ContextPath

江枫思渺然 提交于 2019-12-04 08:10:28
问题 There are a variety of Internal` context functions that are useful, such as InheritedBlock, Bag and StuffBag, etc., as well as many useful Developer` functions. I wish to expose a selection of these symbols such that they may be addressed plainly without the context name, but I do not want to expose all of them by adding Internal` and Developer` to $ContextPath . I could use a proxy symbol such as Bag = Internal`Bag but this is neither clean nor fully correct, since it is a reference, and e.g