Tag Info

New answers tagged

0

This is due to the fact that the first data point pulled (for {2014,8,14}) is used to calculate the first return value, which is on {2014,8,15}. To calculate the return for {2014,8,14} the previous day is needed. In order to get matching starting dates in a reliable way, it is best to determine the starting date, e.g. firstDate={2014, 01, 05} and than ...


3

I ran into the same issue. Dataset and nested Associations have a structure ideally suited for JSON export, but the JSON exporter only supports lists of rules. Any other type of expression triggers the error you see. The workaround is to recursively convert all nested associations to lists of rules. normalAsc[expr_] := expr //. a_Association :> ...


5

For me your command doesn't run. I run: t = QuantityMagnitude[ WeatherData[ "California", "MeanTemperature", {{2013, 1, 1}, {2014, 1, 1}, "Day"} ]["Values"]]; This contains all temperature quantities. A list of dates in your period is easily constructed by DateRange[DateObject[{2013, 1, 1}], DateObject[{2014, 1, 1}]] so ...


2

It seems to me that there are two natural approaches: (1) modifying color rules before the panel is created or (2) post-processing the output to replace recognizable colors. belisarius already showed a method for the second so I shall address the first. Modifying the color rules The color rules are loaded through this call: ...


12

I know you said you didn't want to reinvent the wheel, but sometimes, it's fun to do so. The code below creates a palette with a Periodic Table and a few buttons to make useful tool tips. It shows how one might change the colors based on properties grabbed from ElementData. Note that this code was written for version 9, and if you wish to use it in ...


6

This example picks the colors according to atomic weight, which are loaded from ElementData[]. Like belisarius's answer, it generates a list of rules to replace colors which is then applied to the pane. Rule @@@ Transpose[{ColorData["Atoms", "ColorList"] , ColorData["NeonColors"][QuantityMagnitude@ElementData[#,"AtomicMass"]/200] & /@ ...


14

myAtoms = {"H", "Li", "Na"}; defCols = myAtoms /. ColorData["Atoms", "ColorRules"]; newCols = {Pink, Yellow, LightBlue}; ColorData["Atoms", "Panel"] /. Thread[defCols -> newCols] Edit: Changing the font color isn't related to the ColorRules, but to the special formatting used by the Panel. So it's cumbersome, but you can see that Mma uses a similar ...


1

More of a long comment... You can easily write a function that will enable your end users to Import data from your custom backend. customData[param1_]:= Import[...] customData[param1_, param2_]:= Import[...] customData[param1_, param2_, param3_]:= Import[...] Using different parameter sets in your function definition can give you all the kinds of ...


7

Steven, looking at the data you can see that you already have the latitude and longitude converted into de proper format under fields lng and lat. asamdataset[1] // Normal (*<|"Subregion" -> "57", "Reference" -> "2014-175", "Description" -> "GHANA:On 25 July, the 3,232 gross ton Kiribati-flagged product \ tanker MT HAI SOON 6 was boarded ...


1

First of all, you should avoid using variables names with capital letters : these correspond to built-in functions. Then, if I understood correctly, you want to plot the rows of your data versus time. If so, the following code should work : data = Import["file", "Table"]; time = Range[0, 143/6, 1/60]; ListPlot[Transpose[{time, #}] & /@ data]


4

I feel a bit foolish posting such a simple answer after the two complete examples above, but I think it bears pointing out that version 10 includes a function specifically for removing Missing values: DeleteMissing:


6

This uses some version 10 functions: Getting the data (takes time as I could have set this up better): dat = Table[{i, j, WeatherData[{j, i}, #] & /@ {"WindSpeed", "WindDirection"}}, {i, 113, 153, 4}, {j, -43, -11, 4}]; Processing: data = Cases[{{#1, #2}, -QuantityMagnitude[#3[[1]]] {1/Cos[#2 Degree], 1} Through[{Sin, ...


10

NB I think there's a problem with this code, please see this answer by ubpdqn for more information. I'll update these snippets when I get the chance. Yours is a question with many possible interpretations. I've chosen the interpretation that was most fun for me to play with, so... ang = 20; (* divide the world into chunks of this size *) pts = ...


1

You have two issues - firstly data includes x values and you don't want to convolve those. So use data[[All, 2]] in the convolution. Secondly you need to allow the kernel to overhang the data or you'll just get the single value of the convolution with the kernel aligned to the data. The overhang is determined by the third argument of ListConvolve. See the ...



Top 50 recent answers are included