I want to classify each calendar day from 2005-2025 as spring or neap tide. Is there another function or package to do this?
Spring tide also known as king tide is when the tides are most extreme (higher high tides and lower low tides). Spring tide occurs during the full moon and new moon. Neap tide is the less extreme tides encourage during the half moon phases (waxing and waning moon). I am using this website to determine when the lunar cycle is https://www.calendar-12.com/moon_phases/2022#:~:text=Dates%20of%20Moon%20Phases%20in%202022%20Year%20,%2001%3A42%20PM%20%2028%20more%20rows%20. I also tried using the lunar package to figure out when the dates of the lunar phase are, but ran into issues getting this to work, namely I keep getting the error of an invalid trim argument, but I have already coerced the dates to be in a date format, so I'm not sure why that is happening.
The lunar cycle generally changes the moon phases every week, but there is variation. Typically whenever the moon phase would be spring tide, I will assign three days on either side of the date of the full or new moon to be spring tide days. Days assigned to neap tide are three days on either side of the half moon. Sometimes I have to give or take a day for either assignment when the moon phase change is not exactly 7 days.
So far I have only coded each day by hand in excel (physically typed the word spring or neap in a new column in excel beside the calendar date), but I have 20 years of data to do this for and wanted to find a way to automate it in R. That's why I wondered if a package existed.
Thanks for the help.
What I want my data to look like. In the example, May 8 is a half moon, May 16th is a full moon, May 22nd is a half moon, and May 30th is a new moon.
Code I tried.
dates <- format(seq(as.Date("2005-01-01"), as.Date("2025-01-01"), by="days"), format="%m/%d/%Y")
as.vector(dates)
library(lunar)
lunar.phase(dates, name = TRUE)
I am using the AMAZON.DATE slot and I would like it to default to past dates.
For example, if a user says Monday I would like it to automatically select last Monday rather than next Monday.
In the documentation it confirms that it defaults to 'on or after the current date':
"Utterances that map to a specific date (such as "today", "now", or
"november twenty-fifth") convert to a complete date: 2015-11-25. Note
that this defaults to dates on or after the current date (see below
for more examples)."
For my application there is no way a future date would make sense so it wouldn't be too difficult to manually program this in but I just wondered if there was any other way of doing it?
No, you cannot change the behavior of built in slots, so if Alexa resolves user's answer as a date - before passing it to your further processing just subtract 7 from resolved value. It will give you the date in the past.
I'm working in native C (not C++ - I'd like for everything to stay in C as much as possible) on the Windows API and I'm having trouble with dealing with/comparing UTC strings. Basically I'm getting a date from a WMI call, which as I understand it is a UTC number returned as a DWORD, and I'd like to take a human-readable date-time (i.e. 11:11:11 08/04/2014) and compare that to the UTC date I already have so I can programmatically say which comes before the other.
However it doesn't look like the Windows API provides a good API, and I tried to do it using sscanf_s and mktime similar to the second answer here. This gave me a number that seem close but wasn't quite correct. i.e. both will be today's date within a few minutes has the most significant 3-4 digits the same but nothing else is close.
Is this a timezone/local time problem? Or am I just missing something?
when using a calendar (input with a bind to a date), is there a way to control the interpretation of the input ?
For what I've seen:
1-31 will be the nth of the current month
32-99 is n day after the first of the current month
x0y is the yth day of xth month of the current year
Then it's a little random
511950 will give 05/01/2050
but 151950 will give 01/05/2050
From what i gathered, the control tries to interpret some symbols (any symbol, this includes digits) as separators.
So for example, 151950 is 1/1/50 instead of 1/5/1950 and because it's more than 50 years, the '50' is translated as 2050 instead of 1950.
This is pretty confusing for users, specially when they explicitly put the year with 4 digits and not only 2.
So i'm looking for a way to be a lot stricter. For instance only allowing the dd/mm/yyyy format (with explicit separators). The rest would render the value invalid instead of trying to translate it in something it is not.
Is there a way to do that ?
We're using Orbeon 3.8, and our forms are mostly in french, so dd/mm order.
The parsing is done with regular expressions. See the code here. (To be fair: this code is old!)
I suspect that the overflow conditions are simply a product of the JavaScript date object.
The only way to change this behavior as far as I know is to change the JavaScript code.
I have downloaded a database cities
`Country` `City` `AccentCity` `Region` `Population` `Latitude` `Longitude`
af amir kalay Amir Kalay 16 0 34.6333 70.3333
ad aixas Aixas 06 0 42.4833 1.4667
and lot more records
I have downloaded another database called fips_10_4 to show the state of the city
country,Region,State
AD,02,"Canillo"
AD,03,"Encamp"
AD,04,"La Massana"
AD,05,"Ordino"
AD,06,"Sant Julia de Loria"
AD,07,"Andorra la Vella"
AD,08,"Escaldes-Engordany"
AE,01,"Abu Dhabi"
Now if you are thinking that Iam asking for some sql query then you are wrong.
Everything was working fine but then I came to know that the file i downloaded from
Maxmind website is incomplete as 'fips_10_4' has no record for country 'af' and region '16' .May anybody help me to deal this problem and tell me the correct place to download this complete file
FIPS 10-4 has changed. The list of changes can be found here.
In particular, AF16 (Laghman) has changed to AF35. MaxMind uses the new list.
If you need both the old and the new codes, you can find them here. You can parse the contents of the file, and replace your database table with the information found there.
AF is the two digit ISO code (IS0-3166-2) for Afghanistan, which ISO are currently trying to sell for the frankly astonishing sum of CHF 244 (Swiss Francs).
As Teleo says FIPS 10-4 has changed as detailed on the ITL website and the link Teleo has given provides the data in a more usable format. MaxMind also provides it in a better format.
I would be extremely wary about using this. Both MaxMind & Teleo's link are being provided, for free, by an external company/person that has no particular interest in keeping their data up-to-date. I notice, for instance, that the following countries are missing:
South Sudan
Sint Martaan (Dutch Part)
Bonaire, Sint Eustatius and Saba
Curaçao
The last three were part of the Netherlands Antilles, which was dissolved on 10th October 2010. Incidentally, the Netherlands Antilles, which hasn't existed for a year and a half, is still on this file.
The reason for all of this? FIPS 10-4 was withdrawn almost a decade ago on 8th September 2002. To quote the ITS website (my emphasis):
“For a replacement to FIPS 10-4, INCITS L1 is coordinating with other
standards developers and interested parties to determine whether
processing a draft proposed American National Standard or adopting an
ISO standard would be the better way forward. For more information on
the status of this activity, contact Rick Pearsall
(Richard.A.Pearsall#nga.mil).”
A quick Google brings the news the INCITS L1 is next meeting on the 12th June 2012. I wouldn't hold your breath.
Another reason not to use FIPS is that it is unlikely to be used much outside of the USA (obviously some people will still use it). While this may not matter immediately I would future proof your systems as a matter of course.
I would highly recommend using the ISO 3166 standard. It is a globally recognised way of categorising country data.
The CommonDataHub maintains a great version, which includes country and state in the same manner as FIPS 10-4. They also have other ISO states databases, which are more normalised and worth investigating.
It also maintains a list of all cities with a population greater than 5,000.
ISO maintain a copy on their website of the 3166-2 standard, which will take a bit of coding to ensure it's you're always updated at least you'll be sure it's correct. Wikipedia is also surprisingly good at keeping up-to-date. It beat CommonDataHub by a month when South Sudan was created, due to problems telling people that the data existed.
There are other places out there where this data exists, this just details what I use.
If you want to avoid databases all-together then the Yahoo! PlaceFinder API is a good place to start. It has some documented problems keeping up-to-date but at least there's a place where you can tell them they've got it wrong.
tl;dr
Don't use FIPS, it was withdrawn a decade ago. Use the globally recognised ISO standard instead.
I am not sure what is your true goal, but here is a great resource of countries and cities and all...