Jump to content

Real time weather (METAR) on your server missions HOW TO


Johnny_Rico

Recommended Posts

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>"E:\Programma's\7-Zip\7z.exe" a -tzip ThroughTheInfernoPersianGulfCoopv1.03.zip mission -mx9

Access is denied.

 

 

Looks like you might not have permissions in the folder that file is in to write to it or it is locked by another process eg DCS has it open

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

Thank you for helping me out here Johnny_Rico!

 

I set the permission on C:\ Drive and the "Access is denied" seems to be cleared, but it still won't inject the proper mission time into the .miz file?

 

the weather & date on the other hand is perfectly injected into .miz file

 

dcs_weather.py

 

import os

import re

import sys

import json

import time

import zipfile

import datetime

import requests

import random as rd

# you might need to run this in a command line window if this module is not installed

# pip install requests

 

# real time / weather update script for dcs world (tested under 1.5/2)

# created by havoc-company.com

s_version_info = " V1.1.6 2018.JUN.16_13:05"

 

# usage

# dcs_weather.py <path and file name of mission.miz> <primary_airport code> <backup_airport code> <time control>

# eg

# dcs_weather.py D:\DCS_Missions\Weapons_Training_v2.11.2.miz UGSB UGSS real

# dcs_weather.py D:\DCS_Missions\Weapons_Training_v2.11.2.miz UGSB UGSS rand

# ^ update and use random time of day

# dcs_weather.py D:\DCS_Missions\Weapons_Training_v2.11.2.miz KLAS KLAS 6

# ^ no backup airport and use preset #6 autumn evening

# time control - dawn = 0 1 2 3 dusk = 4 5 6 7

# use real time in mission <time control> = real

# https://www.world-airport-codes.com/ get ICAO code for airport you want to use

# https://www.world-airport-codes.com/alphabetical/country-name/g.html#georgia

# city = 5m , intl = 82m

 

 

class G: # Globals class ...... to store all the data we need to mess with (populate with some defaults)

 

# you need to register with http://www.checkwx.com create an account, then request an api key (takes 24hrs or less)

# once activated your key will appear in your API dashboard http://www.checkwx.com/apikey

# enter your key below between the quotes

s_api_key_checkwx = ':music_whistling:'

 

b_daws_mission = False

 

b_update_weather = True # Set this to False if you do NOT want to use METAR weather

 

s_cloud_base_min = '450'

s_cloud_base_max = '5000'

s_cloud_thickness_min = '200'

s_cloud_thickness_max = '2000'

s_fog_visibility_min = '1800' # use this to limit how much fog visibility will effect things

s_fog_visibility_max = '4200' # was 6000

s_fog_thickness_min = '0'

s_fog_thickness_max = '1000'

 

s_temperature = '8'

 

s_cloud_base_m = '5000'

s_cloud_thickness_m = '380'

s_cloud_density = '5' # few scattered clouds in sky

s_iprecptns = '0'

s_qnh = '760'

 

s_wind_speed_8k = '15'

s_wind_dir_8k = '0'

s_wind_speed_2k = '10'

s_wind_dir_2k = '0'

s_wind_speed_gnd = '0'

s_wind_dir_gnd = '180'

 

s_turbulence = '20'

 

s_fog_enable = 'false' # fog off by default

s_fog_visibility_m = '6000'

s_fog_thickness_m = '0'

s_fog_density = '0'

 

s_primary_airport = '' # EGAA = belfast int 82m above sea level

s_backup_airport = '' # EGAC = city 5m above sea level

s_mission_miz = '' # full name inc path

s_mission_miz_filename = '' # just filename

s_mission_miz_path = '' # path to miz file

 

s_year = ''

s_month = ''

s_day = ''

s_hour = ''

s_mins = ''

s_seconds = ''

s_start_time = ''

i_rand_template = 1

# presets used if time is too late in day and dark eg autumn / winter

l_dates = [['2017', '03', '06', '7', '30'], ['2017', '06', '06', '5', '50'], ['2017', '09', '06', '7', '45'],

['2017', '12', '06', '8', '30'], ['2017', '03', '06', '14', '0'], ['2017', '06', '06', '17', '0'],

['2017', '09', '06', '15', '0'], ['2017', '12', '06', '13', '0']]

b_change_time = False

b_qnh_update = False # set this to True if you want to have the QNH set by METAR data

b_adjust_for_daylight_savings = False # this controls if u want to add one hour to account for clock going forward

i_time_index = 0

 

 

# TODO better less shite command line parsing (but this is test version to see if any problems)

# parse commandline stuff eg airport code / time

if len(sys.argv) < 5:

print("Not enough arguments need more input")

print("usage example")

print('dcs_weather.py "D:\DCS_Missions\Weapons_Training_v2.11.2.miz" UGSB UGSS real')

exit(1)

elif len(sys.argv) == 3:

G.s_backup_airport = str(sys.argv[2]) # set backup to primary

elif len(sys.argv) == 4:

G.s_primary_airport = str(sys.argv[2])

G.s_backup_airport = str(sys.argv[3])

elif len(sys.argv) == 5:

G.s_primary_airport = str(sys.argv[2])

G.s_backup_airport = str(sys.argv[3])

G.b_change_time = True

if str(sys.argv[4]) == 'real':

G.i_time_index = 99

elif str(sys.argv[4]) == 'rand':

G.i_time_index = 100

else:

G.i_time_index = int(sys.argv[4])

# TODO maybe add check for number before setting this

 

# deal with filename and paths

G.s_mission_miz = sys.argv[1]

G.s_mission_miz_path, G.s_mission_miz_filename = os.path.split(sys.argv[1])

G.s_mission_miz_path = G.s_mission_miz_path + '\\'

 

 

def extract_mission_file(s_file_path, s_zip_file_name, s_file_to_extract): # use zip module to get our mission file

s_zip_to_open = s_file_path + s_zip_file_name

if os.path.isfile(G.s_mission_miz):

archive = zipfile.ZipFile(s_zip_to_open)

for file in archive.namelist():

if file.startswith(s_file_to_extract):

archive.extract(file, s_file_path)

else:

print("WARNING: specified miz file does not exist")

exit(1)

 

 

def read_mission_file(s_filename_to_read): # read actual file mission into a list for changing

file = open(s_filename_to_read, "rU", encoding="utf8")

l_content = list(file)

l_content = [x.rstrip('\x0A\x0D') for x in l_content]

if l_content[0] == 'mission = {}': # is this a DAWS mission file ?

G.b_daws_mission = True

return l_content

 

 

def write_mission_file(s_filename_to_write, l_mission): # write mission list into mission file

f = open(s_filename_to_write, 'w', encoding="utf8")

s1 = '\x0D'.join(l_mission)

f.write(s1)

f.close()

change_newline_chars_in_file(s_filename_to_write) # do not ask ..... problems with extra chars being added

 

 

def change_mission_data_item(l_mission, s_item, i_new_value, s_tab='\t\t'): # used to change single unique item value

i_mission_size = len(l_mission)

i_count = 0

s_new_item = s_tab + s_item + str(i_new_value) + ","

 

while i_count < i_mission_size:

if s_item in l_mission[i_count]:

l_mission[i_count] = s_new_item

break

i_count += 1

 

 

def change_newline_chars_in_file(s_filename): # used to deal with extra chars being written to file (0x0D)

with open(s_filename, "rb") as input_file:

content = input_file.read()

content = content.replace(b"\x0D", b"\x0A")

with open(s_filename, "wb") as output_file:

output_file.write(content)

 

 

def convert_feet_to_meters(f_feet): # cos we get data in feet

# 1 foot = 0.3048 meters

f_meters = float(f_feet) * 0.3048

return str(int(f_meters))

 

 

def convert_to_hr_and_min_to_seconds(): # DCS uses seconds from 00:00 as time of day (this converts hr&min to this)

G.s_start_time = str(int(G.s_hour) * 3600 + (int(G.s_mins) * 60) + int(G.s_seconds))

 

 

def convert_knots_to_m_per_sec(f_knots): # used to convert the supplied knots value to meters per second

# 1 knot = 0.514444 m per sec

f_mps = float(f_knots) * 0.514444

return str(int(f_mps))

 

 

def convert_hpa_to_mmhg(f_hpa): # cos we get data in hPa

# 1 hPa = 0.75006157584566 mmHg

f_mmhg = float(f_hpa) * 0.75006157584566

return str(int(round(f_mmhg, 0)))

 

 

def find_item_index_from_start(l_mission, s_search): # used to find which index (first list item) something is

i_index = 0

i_max = len(l_mission)

ret_val = False

while i_index < i_max:

if s_search in l_mission[i_index]:

ret_val = i_index

break

i_index += 1

return ret_val

 

 

def find_item_index(l_mission, s_search, i_stop_position, i_start_position=0): # used to find index of item with params

ret_val = False

i_index = i_start_position

while i_index != i_stop_position:

if s_search in l_mission[i_index]:

return i_index

i_index += 1

return ret_val

 

 

def gen_rand_dev(s_value, i_min, i_max): # used to change values for wind speed / direction at diff alts

i_deviation = rd.randint(i_min, i_max)

i_value = int(s_value) + i_deviation

if i_value < 0:

i_value = 360 + i_value

if i_value >= 360:

i_value -= 360

return str(i_value)

 

 

def not_setup_correctly():

print("")

print("ERROR: You have not set-up you API KEY YET")

print("you need to register with http://www.checkwx.com/ create an account,")

print("then request an api key (takes 24hrs or less)")

print("once activated your key will appear in your API dashboard")

print(" http://www.checkwx.com/apikey ")

print("enter your key in s_api_key_checkwx variable near the top of this script")

time.sleep(30)

exit(1)

 

 

def get_avwx_all_weather_parameters(json_weather_l): # going to read ALL weather info from json then stick it in G vars

G.s_temperature = get_avwx_json_temperature(json_weather_l)

get_avwx_weather_cloud_atmosphere(json_weather_l)

get_avwx_weather_wind(json_weather_l)

s_raw_report = get_avwx_json_raw_report(json_weather_l)

get_avwx_fog_visibility(json_weather_l)

get_weather_fog(s_raw_report)

 

get_weather_turbulence()

 

get_avwx_weather_qnh(json_weather_l)

check_weather_limits() # used to check we are within the limits DCS editor has

 

 

def get_avwx_json_other_list(json_weather_l):

return json_weather_l['Other-List']

 

 

def get_avwx_json_raw_report(json_weather_l):

return json_weather_l['Raw-Report']

 

 

def get_avwx_json_temperature(json_weather_l):

return json_weather_l['Temperature']

 

 

def get_avwx_json_wind_direction(json_weather_l):

s_direction = json_weather_l['Wind-Direction']

if 'VRB' in s_direction: # variable means not measured (unknown)

return str(rd.randint(0, 359))

elif s_direction == '000':

return '0'

else:

return s_direction

 

 

def get_avwx_fog_visibility(json_weather_l):

# set fog view visibility distance (how far you can see before fog obscures stuff)

G.s_fog_visibility_m = json_weather_l['Visibility']

if int(G.s_fog_visibility_m) > int(G.s_fog_visibility_max): # make sure its not out of bounds for DCS

G.s_fog_visibility_m = G.s_fog_visibility_max

 

 

def get_avwx_weather_qnh(json_weather_l):

G.s_qnh = convert_hpa_to_mmhg(json_weather_l['Altimeter'])

 

 

def get_avwx_weather_cloud_atmosphere(json_weather_l): # read json and set the cloud settings from it

# get record count - how many cloud data items do we have

i_max_cloud_records = len(json_weather_l['Cloud-List'])

print("Max records is ", i_max_cloud_records) # debug info

 

# need to make sure there are some clouds first ? is Zero its a CLR day

if i_max_cloud_records == 0:

s_cloud_base = 5000

else:

s_cloud_base = json_weather_l['Cloud-List'][0][1] # set cloud base as first record height (lowest clouds)

 

if i_max_cloud_records == 1:

# if only one cloud record then set cloud alt and cloud type

G.s_cloud_thickness_m = str(rd.randint(200, 300))

G.s_cloud_base_m = convert_feet_to_meters((int(s_cloud_base)) * 100)

s_cloud_cover = json_weather_l['Cloud-List'][0][0]

 

elif i_max_cloud_records > 1:

# if we have multiple cloud records use difference between max and min for cloud depth

G.s_cloud_base_m = convert_feet_to_meters((int(s_cloud_base)) * 100)

s_cloud_alt_max_ft = int(json_weather_l['Cloud-List'][i_max_cloud_records - 1][1]) * 100 # height cl alt ft

s_cloud_alt_min_ft = int(json_weather_l['Cloud-List'][0][1]) * 100 # get low

G.s_cloud_thickness_m = str(convert_feet_to_meters(s_cloud_alt_max_ft - s_cloud_alt_min_ft)) # top to bottom

s_cloud_cover = json_weather_l['Cloud-List'][i_max_cloud_records - 1][0] # get last record cloud type

else:

s_cloud_cover = 'CLR' # stick a default value here (if there is no cloud records)

 

# common parse could cover type into number

G.s_cloud_density = '0' # default value

if s_cloud_cover in ('SKC', 'CLR', 'NSC'):

G.s_cloud_density = '0'

elif s_cloud_cover in 'FEW':

G.s_cloud_density = str(rd.randint(1, 2))

elif s_cloud_cover in 'SCT':

G.s_cloud_density = str(rd.randint(3, 4))

elif s_cloud_cover in 'BKN':

G.s_cloud_density = str(rd.randint(5, 8))

elif s_cloud_cover in 'OVC':

G.s_cloud_density = '9'

G.s_cloud_thickness_m = '200'

elif s_cloud_cover in 'VV':

G.s_cloud_density = str(rd.randint(2, 8))

 

# Rules cloud >= 5 then, ["iprecptns"] = 0 = none , 1 = rain , 2 = thunderstorm(if cloud>=9)

# if temp <=0 then, 3 = snow, 4 = snowstorm(if cloud>=9)

s_raw_report = get_avwx_json_raw_report(json_weather_l)

l_rain = ['RA', 'DZ', 'GR', 'UP']

l_snow = ['SN', 'SG', 'PL']

l_other = ['TS'] # thunderstorm

 

if any(x in s_raw_report for x in l_rain):

# print("RA found")

G.s_iprecptns = '1' # rain

elif any(x in s_raw_report for x in l_snow):

if int(G.s_temperature) <= 2: # is it cold enough for snow/snow storm ?

if int(G.s_cloud_density) >= 9:

G.s_iprecptns = '4' # snow storm

else:

G.s_iprecptns = '3' # snow

elif any(x in s_raw_report for x in l_other):

G.s_cloud_density = '9' # over ride this to match DCS

G.s_iprecptns = '2' # thunderstorm

else:

G.s_iprecptns = '0' # no rain at all

 

 

def get_avwx_weather_wind(json_weather_l): # read json weather data and set the wind info from it

# weather at ground

s_knots = json_weather['Wind-Speed']

s_mps = convert_knots_to_m_per_sec(float(s_knots))

G.s_wind_speed_gnd = s_mps

G.s_wind_dir_gnd = get_avwx_json_wind_direction(json_weather_l) # this function will get a bullshit or real value

 

l_wind_variable_dir = get_avwx_wind_variable_dir(json_weather_l)

i_winds_size = len(l_wind_variable_dir)

 

if l_wind_variable_dir is None:

G.s_wind_speed_gnd = rd.randint(0, 10)

G.s_wind_dir_2k = gen_rand_dev(G.s_wind_dir_gnd, -10, 10)

G.s_wind_dir_8k = gen_rand_dev(G.s_wind_dir_gnd, -20, 20)

else:

if represents_int(l_wind_variable_dir[0]):

if i_winds_size > 1: # must have at least 2

G.s_wind_dir_2k = l_wind_variable_dir[0]

G.s_wind_dir_8k = l_wind_variable_dir[1]

elif i_winds_size == 1: # single

G.s_wind_dir_2k = l_wind_variable_dir[0]

G.s_wind_dir_8k = gen_rand_dev(G.s_wind_dir_gnd, -20, 20) # randomise gnd dir

else:

print("No variable wind ")

G.s_wind_dir_2k = gen_rand_dev(G.s_wind_dir_gnd, -10, 10)

G.s_wind_dir_8k = gen_rand_dev(G.s_wind_dir_gnd, -20, 20)

 

# wind at 2k - we use ground level value and randomise

G.s_wind_speed_2k = gen_rand_dev(s_mps, 1, 3)

 

# wind at 8k - we use ground level value and randomise a bit more

G.s_wind_speed_8k = gen_rand_dev(s_mps, 2, 8)

 

 

def get_avwx_wind_variable_dir(json_weather_l):

return json_weather_l['Wind-Variable-Dir']

 

 

def get_checkwx_json_temperature(json_weather_l):

# get temperature

return str(json_weather_l['data'][0]['temperature']['celsius'])

 

 

def get_checkwx_weather_cloud_atmosphere(json_weather_l):

# get clouds / atmosphere

i_max_cloud_records = len(json_weather_l['data'][0]['clouds'])

print("Max records is ", i_max_cloud_records) # debug info

 

if i_max_cloud_records == 0:

s_cloud_base_m = 5000

else:

s_cloud_base_m = str(int(round(json_weather_l['data'][0]['clouds'][0]['base_meters_agl'], 0)))

# set cloud base as first record height (lowest clouds)

 

if i_max_cloud_records == 1:

# if only one cloud record then set cloud alt and cloud type

G.s_cloud_thickness_m = str(rd.randint(200, 800))

G.s_cloud_base_m = s_cloud_base_m

s_cloud_cover = json_weather_l['data'][0]['clouds'][0]['code']

elif i_max_cloud_records > 1:

# if we have multiple cloud records use difference between max and min for cloud depth

G.s_cloud_base_m = s_cloud_base_m

s_cloud_alt_max_m = int(round(json_weather_l['data'][0]['clouds'][i_max_cloud_records-1]['base_meters_agl'], 0))

s_cloud_alt_min_m = int(round(json_weather_l['data'][0]['clouds'][0]['base_meters_agl'], 0))

G.s_cloud_thickness_m = str(s_cloud_alt_max_m - s_cloud_alt_min_m)

s_cloud_cover = json_weather_l['data'][0]['clouds'][i_max_cloud_records - 1]['code']

else:

s_cloud_cover = 'CLR' # stick a default value here (if there is no cloud records)

 

# common parse could cover type into number

G.s_cloud_density = '0' # default value

if s_cloud_cover in ('SKC', 'CLR', 'NSC'):

G.s_cloud_density = '0'

elif s_cloud_cover in 'FEW':

G.s_cloud_density = str(rd.randint(1, 2))

elif s_cloud_cover in 'SCT':

G.s_cloud_density = str(rd.randint(3, 4))

elif s_cloud_cover in 'BKN':

G.s_cloud_density = str(rd.randint(5, 8))

elif s_cloud_cover in 'OVC':

G.s_cloud_density = '9'

G.s_cloud_thickness_m = '200'

elif s_cloud_cover in 'VV':

G.s_cloud_density = str(rd.randint(2, 8))

 

s_raw_report = str(json_weather_l['data'][0]['raw_text'])

print("raw is ", s_raw_report)

l_rain = ['RA', 'DZ', 'GR', 'UP']

l_snow = ['SN', 'SG', 'PL']

l_other = ['TS'] # thunderstorm

 

if any(x in s_raw_report for x in l_rain):

# print("RA found")

G.s_iprecptns = '1' # rain

elif any(x in s_raw_report for x in l_snow):

if int(G.s_temperature) <= 2: # is it cold enough for snow/snow storm ?

if int(G.s_cloud_density) >= 9:

G.s_iprecptns = '4' # snow storm

else:

G.s_iprecptns = '3' # snow

elif any(x in s_raw_report for x in l_other):

G.s_cloud_density = '9' # over ride this to match DCS

G.s_iprecptns = '2' # thunderstorm

else:

G.s_iprecptns = '0' # no rain at all

 

 

def get_checkwx_weather_qnh(json_weather_l):

G.s_qnh = convert_hpa_to_mmhg(json_weather_l['data'][0]['barometer']['mb'])

 

 

def get_checkwx_weather_wind(json_weather_l):

# get wind

i_wind_records = len(json_weather_l['data'][0]['wind'])

s_direction = str(json_weather_l['data'][0]['wind']['degrees'])

if s_direction is None:

s_direction = '0'

 

if 'VRB' in s_direction: # variable means not measured (unknown)

s_direction = str(rd.randint(0, 359))

s_mps = str(rd.randint(0, 20))

G.s_wind_speed_gnd = str(s_mps)

else:

if i_wind_records > 1:

s_mps = int(json_weather_l['data'][0]['wind']['speed_mps'])

G.s_wind_speed_gnd = str(s_mps)

else:

s_direction = '0'

 

G.s_wind_dir_gnd = str(s_direction)

G.s_wind_dir_2k = gen_rand_dev(G.s_wind_dir_gnd, -10, 10)

G.s_wind_dir_8k = gen_rand_dev(G.s_wind_dir_gnd, -20, 20)

G.s_wind_speed_2k = gen_rand_dev(G.s_wind_speed_gnd, 1, 3)

G.s_wind_speed_8k = gen_rand_dev(G.s_wind_speed_gnd, 2, 8)

 

 

def get_checkwx_fog_visibility(json_weather_l):

# set fog view visibility distance (how far you can see before fog obscures stuff)

i_tmp = json_weather_l['data'][0]['visibility']['meters']

i_tmp = re.sub('[,+]', '', i_tmp)

G.s_fog_visibility_m = i_tmp

print(G.s_fog_visibility_m)

 

 

def get_checkwx_all_weather_parameters(json_weather_l):

G.s_temperature = get_checkwx_json_temperature(json_weather_l)

get_checkwx_weather_cloud_atmosphere(json_weather_l)

get_checkwx_weather_wind(json_weather_l)

 

s_raw_report = json_weather_l['data'][0]['raw_text']

 

get_checkwx_fog_visibility(json_weather_l)

 

get_weather_fog(s_raw_report)

 

# turbulence

get_weather_turbulence()

get_checkwx_weather_qnh(json_weather)

# weather limits

check_weather_limits()

 

 

def get_weather_turbulence():

# 0 is nothing, 60 is crap your pants time .... 0.1* m = 6mps

 

i_wind_speed_gnd = int(G.s_wind_speed_gnd)

# print("wind sped gnd ", i_wind_speed_gnd)

if i_wind_speed_gnd <= 5:

i_min_turbulence = 0

i_max_turbulence = 12

if 6 <= i_wind_speed_gnd <= 10:

i_min_turbulence = 12

i_max_turbulence = 25

if 11 <= i_wind_speed_gnd <= 15:

i_min_turbulence = 15

i_max_turbulence = 35

if 16 <= i_wind_speed_gnd <= 20:

i_min_turbulence = 25

i_max_turbulence = 50

if 21 <= i_wind_speed_gnd <= 25:

i_min_turbulence = 30

i_max_turbulence = 60

if i_wind_speed_gnd > 30:

i_min_turbulence = 35

i_max_turbulence = 70

# print("Turb min ", i_min_turbulence, " max ", i_max_turbulence)

G.s_turbulence = str(rd.randint(i_min_turbulence, i_max_turbulence))

 

 

def get_mission_date_time(): # get the time date store in G.

if G.i_time_index == 100:

G.s_start_time = str(rd.randint(0, 86400))

return

 

elif G.i_time_index == 99: # this is for real server time to set mission time

# do real time calc stuff here

a = datetime.datetime.now()

now = a + datetime.timedelta(0, 180) # add 180 seconds as it takes this long to spool the server up and load

# due to summer/winter time check if between change date then + 1

d_start = datetime.date(now.year, 10, 29)

d_now_date = datetime.date(now.year, now.month, now.day)

d_end = datetime.date(now.year + 1, 3, 26)

if G.b_adjust_for_daylight_savings:

if d_start < d_now_date < d_end:

now = a + datetime.timedelta(0, 3780) # add 1 hour 180 seconds forward

 

G.s_year = str(now.year)

G.s_month = str(now.month)

G.s_day = str(now.day)

G.s_hour = str(now.hour)

G.s_mins = str(now.minute)

G.s_seconds = str(now.second)

else:

# do time array stuff here

G.s_year = G.l_dates[G.i_time_index][0]

G.s_month = G.l_dates[G.i_time_index][1]

G.s_day = G.l_dates[G.i_time_index][2]

G.s_hour = G.l_dates[G.i_time_index][3]

G.s_mins = G.l_dates[G.i_time_index][4]

G.s_seconds = str(0)

convert_to_hr_and_min_to_seconds()

 

 

def check_weather_limits():

# created this to make sure values fall within the acceptable range that can be configured in the DCS editor

# dcs has a hard base limit of 300m, think we should be above it as people bitch about it

s_base_tmp = G.s_cloud_base_m

 

if int(G.s_cloud_base_m) <= int(G.s_cloud_base_min): # going for ?

i_diff = abs(int(s_base_tmp) - int(G.s_cloud_base_min))

G.s_cloud_base_m = G.s_cloud_base_min

G.s_cloud_thickness_m = str(int(G.s_cloud_thickness_m) + int(i_diff))

 

if int(G.s_cloud_thickness_m) <= int(G.s_cloud_thickness_min):

G.s_cloud_thickness_m = '200'

 

if int(G.s_fog_visibility_m) >= int(G.s_fog_visibility_max): # make sure its not out of bounds for DCS

G.s_fog_visibility_m = G.s_fog_visibility_max

 

if int(G.s_fog_visibility_m) <= int(G.s_fog_visibility_min):

G.s_fog_visibility_m = G.s_fog_visibility_min

 

if int(G.s_cloud_density) >= 9 or G.s_fog_enable == 'true' and int(G.s_cloud_base_m) <= 2000:

G.s_cloud_base_m = '2000'

 

 

def get_weather_fog(s_raw_report): # read raw report and see if any fog markers

l_fog = ['BR', 'FG', 'FU', 'VA', 'DU', 'SA', 'HZ', 'PY'] # codes for obscure weather

if not any(x in s_raw_report for x in l_fog): # search it for ANY fog tags

# print("Fog NOT found") # debug info

if int(G.s_fog_visibility_m) >= 6000 or G.s_iprecptns == '0': # if def val for dist intact? or greater than

G.s_fog_enable = 'false'

return False # bail out and leave defaults as is

 

G.s_fog_enable = 'true'

G.s_fog_thickness_m = str(500 + rd.randint(-50, 200)) # generate a random thickness value

G.s_fog_density = '7' # set it to ON

 

 

def retrieve_json_data_from_web(s_request, s_header=None): # connect to url and grab METAR data

print(s_request)

try: # Can we get connect to the website..... Better check first

response = requests.get(s_request, headers=s_header, timeout=8)

response.raise_for_status()

except requests.exceptions.HTTPError:

print(requests.exceptions.HTTPError)

return False

except requests.exceptions.ReadTimeout:

print("HTTP read time out")

return False

except requests.exceptions.Timeout:

print("HTTP time out")

return False

except requests.exceptions.TooManyRedirects:

print("Too many re-directs")

return False

except requests.exceptions.RequestException as e: # catch any problem and print out what it is here

print(e)

sys.exit(1)

else:

print(response.text) # print out raw data

json_object = json.loads(response.text)

if json_object is False:

return False

if 'Error' in json_object: # this is to cover sometimes getting an error string from the server

# print(json_object)

return False

print(json_object)

return json_object

 

 

def weather_read_url_checkwx(): # try to read metar data for airport(s) from internet

if G.s_api_key_checkwx == 'NOT_SET_YET':

not_setup_correctly()

 

s_url1 = 'https://api.checkwx.com/metar/' + G.s_primary_airport + '/decoded'

s_url2 = 'https://api.checkwx.com/metar/' + G.s_backup_airport + '/decoded'

s_headers = {'X-API-Key': G.s_api_key_checkwx}

 

json_object = False # just stuck this here to stick pycharm whining like a little bitch

# we should try primary twice with a 5 second wait between attempts

i_count = 0

while i_count < 1:

json_object = retrieve_json_data_from_web(s_url1, s_headers) # try primary airport

if json_object is not False:

break

time.sleep(5)

i_count += 1

 

if json_object is False:

i_count = 0

while i_count < 2:

json_object = retrieve_json_data_from_web(s_url2, s_headers) # try backup airport

if json_object is not False:

break

time.sleep(5)

i_count += 1

 

return json_object

 

 

def weather_read_url_avwx(): # try to read metar data for airport(s) from internet

s_url_base = "https://avwx.rest/api/metar/"

s_url1 = s_url_base + G.s_primary_airport

s_url2 = s_url_base + G.s_backup_airport

json_object = False # just stuck this here to stick pycharm whining like a little bitch

 

# we should try primary twice with a 5 second wait between attempts

i_count = 0

while i_count < 1:

json_object = retrieve_json_data_from_web(s_url1) # try primary airport

if json_object is not False:

break

time.sleep(5)

i_count += 1

 

if json_object is False:

i_count = 0

while i_count < 2:

json_object = retrieve_json_data_from_web(s_url2) # try backup airport

if json_object is not False:

break

time.sleep(5)

i_count += 1

 

return json_object

 

 

def save_cloud_atmosphere(l_mission): # save cloud data into mission file list

s_cloud_start = '["clouds"]'

s_daws_cloud_start = 'mission["weather"]["clouds"]["thickness"] = '

s_thickness = '["thickness"] = '

s_dense = '["density"] = '

s_cloud_base = '["base"] = '

s_cloud_rain = '["iprecptns"] = '

 

i_max_line = len(l_mission)

 

if G.b_daws_mission:

i_start_clouds = find_item_index(l_mission, s_daws_cloud_start, i_max_line)

l_mission[i_start_clouds] = s_daws_cloud_start + G.s_cloud_thickness_m # thickness of clouds

l_mission[i_start_clouds + 1] = 'mission["weather"]["clouds"]["density"] = ' + G.s_cloud_density

l_mission[i_start_clouds + 2] = 'mission["weather"]["clouds"]["base"] = ' + G.s_cloud_base_m

l_mission[i_start_clouds + 3] = 'mission["weather"]["clouds"]["iprecptns"] = ' + G.s_iprecptns

 

else:

# get record count (mission list size)

i_start_clouds = find_item_index(l_mission, s_cloud_start, i_max_line) # omitting start means begin index @ 0

 

l_mission[i_start_clouds + 2] = '\t\t\t' + s_thickness + G.s_cloud_thickness_m + "," # thickness of clouds

l_mission[i_start_clouds + 3] = '\t\t\t' + s_dense + G.s_cloud_density + "," # density of clouds

l_mission[i_start_clouds + 4] = '\t\t\t' + s_cloud_base + G.s_cloud_base_m + "," # cloud base

 

change_mission_data_item(l_mission, s_cloud_rain, G.s_iprecptns, '\t\t\t')

# l_mission[i_start_clouds + 5] = '\t\t\t' + s_cloud_rain + G.s_iprecptns + ","

 

 

def save_date_and_time(l_mission): # save time/date info into mission list

s_year = 'mission["date"]["Year"] ='

s_day = 'mission["date"]["Day"] = '

s_month = 'mission["date"]["Month"] = '

i_mission_size = len(l_mission)

 

if G.b_daws_mission:

if G.i_time_index != 100:

i_date_start = find_item_index(l_mission, 'mission["date"] = {}', i_mission_size)

l_mission[i_date_start + 1] = s_year + G.s_year

l_mission[i_date_start + 2] = s_day + G.s_day

l_mission[i_date_start + 3] = s_month + G.s_month

else:

change_mission_data_item(l_mission, 'mission["start_time"] = ', str(G.s_start_time), '')

else:

if G.i_time_index != 100:

# set year , month and date in mission

change_mission_data_item(l_mission, '["Year"] = ', str(G.s_year))

# month

change_mission_data_item(l_mission, '["Month"] = ', str(G.s_month))

# day

change_mission_data_item(l_mission, '["Day"] = ', str(G.s_day))

# time, hmm tricky find ["forcedOptions"] then -1 write value cos it will be start_time in seconds 00:00

# because start_time appears a lot thru the mission file

else:

i_forced = find_item_index(l_mission, '["forcedOptions"]', i_mission_size)

l_mission[i_forced-1] = '\t' + '["start_time"] = ' + G.s_start_time + ','

 

 

def save_data_to_mission(l_mission): # save all data we have into mission list

s_temp = '["temperature"] = '

s_temp_daws = 'mission["weather"]["season"]["temperature"] = '

s_turb = '["groundTurbulence"] = '

s_turb_daws = 'mission["weather"]["groundTurbulence"] = '

 

save_cloud_atmosphere(l_mission)

save_wind(l_mission)

save_qnh(l_mission)

save_fog(l_mission)

if G.b_daws_mission:

i_max_line = len(l_mission)

i_start_turb = find_item_index(l_mission, s_turb_daws, i_max_line)

l_mission[i_start_turb] = s_turb_daws + G.s_turbulence

i_start_temp = find_item_index(l_mission, s_temp_daws, i_max_line)

l_mission[i_start_temp] = s_temp_daws + G.s_temperature

else:

change_mission_data_item(l_mission, s_turb, G.s_turbulence, '\t\t\t')

change_mission_data_item(l_mission, s_temp, G.s_temperature, '\t\t\t')

 

 

def save_qnh(l_mission):

s_qnh = '["qnh"] = '

s_qnh_daws = 'mission["weather"]["qnh"] = '

if not G.b_qnh_update:

return

if G.b_daws_mission:

i_max_line = len(l_mission)

i_start_qnh = find_item_index(l_mission, s_qnh_daws, i_max_line)

l_mission[i_start_qnh] = s_qnh_daws + G.s_qnh

else:

change_mission_data_item(l_mission_data, s_qnh, G.s_qnh, '\t\t')

 

 

def save_fog(l_mission): # save fog data into mission list

s_fog_start = '["fog"]'

s_fog_vis = '["visibility"] = '

s_fog_enable = '["enable_fog"] = '

s_fog_enable_daws = 'mission["weather"]["enable_fog"] = '

s_thickness = '["thickness"] = '

s_fog_density = '["density"] = '

s_fog_start_daws = 'mission["weather"]["fog"]["thickness"] = '

 

i_max_line = len(l_mission)

 

if G.b_daws_mission:

i_fog_start = find_item_index(l_mission, s_fog_start_daws, i_max_line)

l_mission[i_fog_start] = s_fog_start_daws + G.s_fog_thickness_m

l_mission[i_fog_start + 1] = 'mission["weather"]["fog"]["visibility"] = ' + G.s_fog_visibility_m

l_mission[i_fog_start + 2] = 'mission["weather"]["fog"]["density"] = ' + G.s_fog_density

i_fog_en = find_item_index(l_mission, s_fog_enable_daws, i_max_line)

l_mission[i_fog_en] = s_fog_enable_daws + G.s_fog_enable

else:

# find start of fog data stuff

i_fog_start = find_item_index_from_start(l_mission, s_fog_start)

change_mission_data_item(l_mission_data, s_fog_enable, G.s_fog_enable, '\t\t') # enable fog flag

# set fog thickness (height above ground before fog

l_mission[i_fog_start + 2] = '\t\t\t' + s_thickness + G.s_fog_thickness_m + "," # fog view thickness

 

# set fog view visibility distance (how far you can see before fog obscures stuff)

l_mission[i_fog_start + 3] = '\t\t\t' + s_fog_vis + G.s_fog_visibility_m + "," # fog view visibility

 

# set fog density - **** knows what this does but 7 seems ok

l_mission[i_fog_start + 4] = '\t\t\t' + s_fog_density + G.s_fog_density + "," # fog density

 

 

def save_wind(l_mission): # save wind speed direction info into mission list

s_wind_speed = '["speed"] = '

s_wind_dir = '["dir"] = '

s_wind_at_8k = '["at8000"]'

s_wind_at_gnd = '["atGround"]'

s_wind_at_2k = '["at2000"]'

s_wind_start8k = 'mission["weather"]["wind"]["at8000"]["speed"] = '

s_wind_startgnd = 'mission["weather"]["wind"]["atGround"]["speed"] = '

s_wind_start2k = 'mission["weather"]["wind"]["at2000"]["speed"] = '

 

i_max_line = len(l_mission)

 

if G.b_daws_mission:

i_start_wind8k = find_item_index(l_mission, s_wind_start8k, i_max_line)

l_mission[i_start_wind8k] = s_wind_start8k + G.s_wind_speed_8k

l_mission[i_start_wind8k + 1] = 'mission["weather"]["wind"]["at8000"]["dir"] = ' + G.s_wind_dir_8k

 

i_start_windgnd = find_item_index(l_mission, s_wind_startgnd, i_max_line)

l_mission[i_start_windgnd] = s_wind_startgnd + G.s_wind_speed_gnd

l_mission[i_start_windgnd + 1] = 'mission["weather"]["wind"]["atGround"]["dir"] = ' + G.s_wind_dir_gnd

 

i_start_wind2k = find_item_index(l_mission, s_wind_start2k, i_max_line)

l_mission[i_start_wind2k] = s_wind_start2k + G.s_wind_speed_2k

l_mission[i_start_wind2k + 1] = 'mission["weather"]["wind"]["at2000"]["dir"] = ' + G.s_wind_dir_2k

 

else:

# find start of WIND ground section

i_start_wind_at_gnd = find_item_index(l_mission, s_wind_at_gnd, i_max_line) # omitting start begin index @ 0

l_mission[i_start_wind_at_gnd + 2] = '\t\t\t\t' + s_wind_speed + G.s_wind_speed_gnd + ","

l_mission[i_start_wind_at_gnd + 3] = '\t\t\t\t' + s_wind_dir + G.s_wind_dir_gnd + ","

 

# find start of WIND 2K section

i_start_wind_at_2k = find_item_index(l_mission, s_wind_at_2k, i_max_line) # omitting start begin index @ 0

l_mission[i_start_wind_at_2k + 2] = '\t\t\t\t' + s_wind_speed + G.s_wind_speed_2k + ","

l_mission[i_start_wind_at_2k + 3] = '\t\t\t\t' + s_wind_dir + G.s_wind_dir_2k + ","

 

# find start of WIND 8K section

i_start_wind_at_8k = find_item_index(l_mission, s_wind_at_8k, i_max_line) # omitting start begin index @ 0

l_mission[i_start_wind_at_8k + 2] = '\t\t\t\t' + s_wind_speed + G.s_wind_speed_8k + ","

l_mission[i_start_wind_at_8k + 3] = '\t\t\t\t' + s_wind_dir + G.s_wind_dir_8k + ","

 

 

def print_all_data(): # debug just so we can see what values we have

print("b_daws_mission is ", G.b_daws_mission)

print("s_temperature is ", G.s_temperature)

print("s_cloud_thickness_m is ", G.s_cloud_thickness_m)

print("s_cloud_density is ", G.s_cloud_density)

print("s_cloud_base_m is ", G.s_cloud_base_m)

print("s_iprecptns is ", G.s_iprecptns)

print("s_qnh is ", G.s_qnh)

print("s_wind_speed_8k is ", G.s_wind_speed_8k)

print("s_wind_dir_8k is ", G.s_wind_dir_8k)

print("s_wind_speed_2k is ", G.s_wind_speed_2k)

print("s_wind_dir_2k is ", G.s_wind_dir_2k)

print("s_wind_speed_gnd is ", G.s_wind_speed_gnd)

print("s_wind_dir_gnd is ", G.s_wind_dir_gnd)

print("s_turbulence is ", G.s_turbulence)

print("s_fog_enable ", G.s_fog_enable)

print("s_fog_visibility_m ", G.s_fog_visibility_m)

print("s_fog_thickness_m ", G.s_fog_thickness_m)

print("s_fog_density ", G.s_fog_density)

print("s_primary_airport ", G.s_primary_airport)

print("s_backup_airport ", G.s_backup_airport)

print("s_year ", G.s_year)

print("s_month ", G.s_month)

print("s_day ", G.s_day)

print("s_hour ", G.s_hour)

print("s_mins ", G.s_mins)

print("s_seconds ", G.s_seconds)

print("s_start_time ", G.s_start_time)

print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")

 

 

def represents_int(s_value):

try:

int(s_value)

return True

except ValueError:

return False

 

 

# extract mission file from mission miz

extract_mission_file(G.s_mission_miz_path, G.s_mission_miz_filename, 'mission')

 

# read mission file into a list item

l_mission_data = read_mission_file(G.s_mission_miz_path + 'mission')

 

# get realtime date and change in mission file (if necessary)

if G.b_change_time:

get_mission_date_time()

save_date_and_time(l_mission_data)

 

print_all_data() # debug just for seeing what things started at

 

if G.b_update_weather:

# first try the primary (first site) and see of we get data ok

json_weather = weather_read_url_checkwx()

if json_weather is not False:

# set values in G array

get_checkwx_all_weather_parameters(json_weather)

 

else: # this is to cover primary website data read failing for some reason

# try secondary

json_weather = weather_read_url_avwx()

if json_weather is not False:

# set values in G array

get_avwx_all_weather_parameters(json_weather)

else:

print("WARNING - METAR data read failure")

print("Using default weather values instead")

 

 

save_data_to_mission(l_mission_data) # write G. global variables for weather into mission list

print_all_data() # debug just for seeing what things actually are in the file

 

write_mission_file('mission', l_mission_data) # now take mission list and write it back to file

 

print("weather.py", s_version_info, " exiting")

 

 

 

weather.bat

 

: example launch file for DCS used with dcs_weather.py

: by havoc-company.com

: you need python 3 and 7z installed on server hosting PC

: you will need to edit this file to change parameters to match your install

: contact Johnny Rico in ED forums for any queries

: V 1.0.1

 

SET DCS_PATH="D:\Games\Eagle Dynamics\DCS World OpenBeta\bin"

 

 

: settings for dcs_weather.py - airports weather to query

SET PRIMARY_AIRPORT=OMDB

SET BACKUP_AIRPORT=OMDM

: you want to use current realtime on server ?

SET TIME_CONTROL=real

 

: set this to where your 7z.exe is installed

SET zip="E:\Programma's\7-Zip\7z.exe"

 

: where you store your mission miz files

SET MISSION_PATH="C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03"

 

: mission name minus the file extension

SET MISSION_NAME=ThroughTheInfernoPersianGulfCoopv1.03

 

: path and name of weather python script

SET PYTHON_SCRIPT="D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather\dcs_weather.py"

 

 

SET TEST=%time:~0,1%

SET HOUR=%time:~0,2%

IF "%TEST%" == " " SET HOUR=%time:~1,1%

 

 

: this override was added so that if it is too late in the year (dark a lot in evenings) then people would get some time were it is light for a bit

: IF %HOUR% GEQ 18 TIME_CONTROL=6

@echo %TIME_CONTROL%

 

 

cd /D %MISSION_PATH%

%PYTHON_SCRIPT% %MISSION_PATH%%MISSION_NAME%.miz %PRIMARY_AIRPORT% %BACKUP_AIRPORT% %TIME_CONTROL%

 

: rename .miz to .zip because 7z don't like miz file extension

ren %MISSION_NAME%.miz %MISSION_NAME%.zip

 

: add the updated mission to the zip file

%zip% a -tzip %MISSION_NAME%.zip mission -mx9

 

: rename it back to miz

ren %MISSION_NAME%.zip %MISSION_NAME%.miz

 

 

cd /D %DCS_PATH%

start /D%DCS_PATH% /B dcs.exe

 

 

pause

 

 

Most Recent CMD log

 

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET DCS_PATH="D:\Games\Eagle Dynamics\DCS World OpenBeta\bin"

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET PRIMARY_AIRPORT=OMDB

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET BACKUP_AIRPORT=OMDM

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET TIME_CONTROL=real

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET zip="E:\Programma's\7-Zip\7z.exe"

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET MISSION_PATH="C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03"

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET MISSION_NAME=ThroughTheInfernoPersianGulfCoopv1.03

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET PYTHON_SCRIPT="D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather\dcs_weather.py"

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET TEST=2

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>SET HOUR=20

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>IF "2" == " " SET HOUR=0

real

 

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather>cd /D "C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03"

 

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>"D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather\dcs_weather.py" "C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03"ThroughTheInfernoPersianGulfCoopv1.03.miz OMDB OMDM real

D:\Games\Eagle Dynamics\DCS Real Weather Script's\dcs_weather Through the Inferno\DCS Realtime Weather\dcs_weather.py:141: DeprecationWarning: 'U' mode is deprecated

file = open(s_filename_to_read, "rU", encoding="utf8")

b_daws_mission is False

s_temperature is 8

s_cloud_thickness_m is 380

s_cloud_density is 5

s_cloud_base_m is 5000

s_iprecptns is 0

s_qnh is 760

s_wind_speed_8k is 15

s_wind_dir_8k is 0

s_wind_speed_2k is 10

s_wind_dir_2k is 0

s_wind_speed_gnd is 0

s_wind_dir_gnd is 180

s_turbulence is 20

s_fog_enable false

s_fog_visibility_m 6000

s_fog_thickness_m 0

s_fog_density 0

s_primary_airport OMDB

s_backup_airport OMDM

s_year 2018

s_month 7

s_day 9

s_hour 20

s_mins 32

s_seconds 25

s_start_time 73945

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

https://api.checkwx.com/metar/OMDB/decoded

{

"results": 1,

"data": [

{

"icao": "OMDB",

"name": "Dubai International",

"observed": "09-07-2018 @ 18:00Z",

"raw_text": "OMDB 091800Z 13006KT 8000 NSC 40\/14 Q0995 NOSIG",

"barometer": {

"hg": 29.38,

"kpa": 99.49,

"mb": 995

},

"clouds": [

{

"code": "CLR",

"text": "Clear skies",

"base_feet_agl": 0,

"base_meters_agl": 0

}

],

"dewpoint": {

"celsius": 14,

"fahrenheit": 57

},

"elevation": {

"feet": 16,

"meters": 5

},

"flight_category": "MVFR",

"humidity_percent": 21,

"temperature": {

"celsius": 40,

"fahrenheit": 104

},

"visibility": {

"miles": "41\/97",

"meters": "7,998"

},

"wind": {

"degrees": 130,

"speed_kts": 6,

"speed_mph": 7,

"speed_mps": 3

}

}

]

}

{'results': 1, 'data': [{'icao': 'OMDB', 'name': 'Dubai International', 'observed': '09-07-2018 @ 18:00Z', 'raw_text': 'OMDB 091800Z 13006KT 8000 NSC 40/14 Q0995 NOSIG', 'barometer': {'hg': 29.38, 'kpa': 99.49, 'mb': 995}, 'clouds': [{'code': 'CLR', 'text': 'Clear skies', 'base_feet_agl': 0, 'base_meters_agl': 0}], 'dewpoint': {'celsius': 14, 'fahrenheit': 57}, 'elevation': {'feet': 16, 'meters': 5}, 'flight_category': 'MVFR', 'humidity_percent': 21, 'temperature': {'celsius': 40, 'fahrenheit': 104}, 'visibility': {'miles': '41/97', 'meters': '7,998'}, 'wind': {'degrees': 130, 'speed_kts': 6, 'speed_mph': 7, 'speed_mps': 3}}]}

Max records is 1

raw is OMDB 091800Z 13006KT 8000 NSC 40/14 Q0995 NOSIG

7998

b_daws_mission is False

s_temperature is 40

s_cloud_thickness_m is 678

s_cloud_density is 0

s_cloud_base_m is 450

s_iprecptns is 0

s_qnh is 746

s_wind_speed_8k is 6

s_wind_dir_8k is 147

s_wind_speed_2k is 6

s_wind_dir_2k is 135

s_wind_speed_gnd is 3

s_wind_dir_gnd is 130

s_turbulence is 4

s_fog_enable false

s_fog_visibility_m 4200

s_fog_thickness_m 0

s_fog_density 0

s_primary_airport OMDB

s_backup_airport OMDM

s_year 2018

s_month 7

s_day 9

s_hour 20

s_mins 32

s_seconds 25

s_start_time 73945

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

weather.py V1.1.6 2018.JUN.16_13:05 exiting

 

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>ren ThroughTheInfernoPersianGulfCoopv1.03.miz ThroughTheInfernoPersianGulfCoopv1.03.zip

 

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>"E:\Programma's\7-Zip\7z.exe" a -tzip ThroughTheInfernoPersianGulfCoopv1.03.zip mission -mx9

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>ren ThroughTheInfernoPersianGulfCoopv1.03.zip ThroughTheInfernoPersianGulfCoopv1.03.miz

 

C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03>cd /D "D:\Games\Eagle Dynamics\DCS World OpenBeta\bin"

 

D:\Games\Eagle Dynamics\DCS World OpenBeta\bin>start /D"D:\Games\Eagle Dynamics\DCS World OpenBeta\bin" /B dcs.exe

 

D:\Games\Eagle Dynamics\DCS World OpenBeta\bin>pause

Press any key to continue . . .

 

 

Mission editor Date & Time

 

Throug%20the%20inferno%20Real%20weather%20time%20problem_zpspsaqsni7.png

 

 

Mission editor Weather

 

Throug%20the%20inferno%20Real%20weather%20good_zpsbvul6ytj.png

 

 

Intel® Core™ i7-6900K Processor (watercooled) - Asus ROG Rampage V Edition 10 (watercooled) motherbord - 8 x 8Gb Corsair Vengeance LPX DDR4-3333Mhz RAM (watercooled) - 2 x ROG-STRIX-GTX1080TI-11G-GAMING (watercooled)

- Creative X-Fi Titanium Fatal1ty Pro - Logitech G910 Orion Spark - Asus PG348 34'' LCD screen - Razor Tiamat 7.1 - Thrustmaster HOTAS Warthog Replica USAF A-10C - TrackIR 5 - Pro Flight Cessna Rudder Pedals - VAICOM 2.5 PRO

 

Link to comment
Share on other sites

hmmm, I canny see any errors

try this

 

 

go to the folder where the mission is

open the file "mission" in notepad++

run the batch file

see if notepad++ says "this file has been updated do you want to reload it"

at least we can see if the file is being updated by the py file


Edited by Johnny_Rico

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

Thank you for helping me out here Johnny_Rico!

 

I set the permission on C:\ Drive and the "Access is denied" seems to be cleared, but it still won't inject the proper mission time into the .miz file?

 

the weather & date on the other hand is perfectly injected into .miz file

 

weather.bat

 

: where you store your mission miz files

SET MISSION_PATH="C:\Users\tommy\Saved Games\DCS.openbeta\Missions\Persian Gulf\Downloaded\ThroughTheInfernoPersianGulfv1.03"

 

I tried this script and got it working on the latest stable 2.5.2 release.

On my first attempt it didn't work because the white space included in the mission path throw some error. I've simply moved the mission from default "saved games" folder to the "D:\DCS_mission" and it works like a charm.

 

Thanks to havoc company to share with us this work! Maybe in the future we're going to use it on our server!


Edited by Maverick87Shaka

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

hmmm, I canny see any errors

try this

 

 

go to the folder where the mission is

open the file "mission" in notepad++

run the batch file

see if notepad++ says "this file has been updated do you want to reload it"

at least we can see if the file is being updated by the py file

 

yes it does say when i close Notepad++ "This file has been modified by another program. Do you want to reload it?"

 

but i already assumed that the file is being updated by the py file, because the weather & the date are being updated, but the real time doesn't?

 

i did everything (except reading the installation manual very carefully at the beginning :music_whistling:) by the book and did not alter any text in the py file and weather.bat?

 

i'm going to redownload a fresh start and i'll begin from step 1 again, maybe i leaned on a wrong key or something?

 

EDIT

 

i compared the dcs_weather.py & weather.bat with fresh downloaded original files with the notepad++ compare plugin, and everything is oke (only the lines that need to be changed are changed). so no corrupted .py and .bat due to typo's or something!?


Edited by Bottle-RUM

 

Intel® Core™ i7-6900K Processor (watercooled) - Asus ROG Rampage V Edition 10 (watercooled) motherbord - 8 x 8Gb Corsair Vengeance LPX DDR4-3333Mhz RAM (watercooled) - 2 x ROG-STRIX-GTX1080TI-11G-GAMING (watercooled)

- Creative X-Fi Titanium Fatal1ty Pro - Logitech G910 Orion Spark - Asus PG348 34'' LCD screen - Razor Tiamat 7.1 - Thrustmaster HOTAS Warthog Replica USAF A-10C - TrackIR 5 - Pro Flight Cessna Rudder Pedals - VAICOM 2.5 PRO

 

Link to comment
Share on other sites

yes it does say when i close Notepad++ "This file has been modified by another program. Do you want to reload it?"

 

but i already assumed that the file is being updated by the py file, because the weather & the date are being updated, but the real time doesn't?

 

i did everything (except reading the installation manual very carefully at the beginning :music_whistling:) by the book and did not alter any text in the py file and weather.bat?

 

i'm going to redownload a fresh start and i'll begin from step 1 again, maybe i leaned on a wrong key or something?

Give a try with a Mission folder that doesn't contain space in the name.

I moved my mission from "BlaBla\Saved Games\BalBla" to C:\DCS_Missions\ and I solved all my problem ;)

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

Give a try with a Mission folder that doesn't contain space in the name.

I moved my mission from "BlaBla\Saved Games\BalBla" to C:\DCS_Missions\ and I solved all my problem ;)

 

i tried before, and now again and what you say is true, it doesn't like spaces in file names.

 

but still the weather and date is injected perfectly, only the time doesn't.

 

but thanks anyways for your input on the matter Maverick87Shaka :thumbup:


Edited by Bottle-RUM

 

Intel® Core™ i7-6900K Processor (watercooled) - Asus ROG Rampage V Edition 10 (watercooled) motherbord - 8 x 8Gb Corsair Vengeance LPX DDR4-3333Mhz RAM (watercooled) - 2 x ROG-STRIX-GTX1080TI-11G-GAMING (watercooled)

- Creative X-Fi Titanium Fatal1ty Pro - Logitech G910 Orion Spark - Asus PG348 34'' LCD screen - Razor Tiamat 7.1 - Thrustmaster HOTAS Warthog Replica USAF A-10C - TrackIR 5 - Pro Flight Cessna Rudder Pedals - VAICOM 2.5 PRO

 

Link to comment
Share on other sites

open dcs_weather.py in notepad++

 

search for

b_change_time = False

change to

b_change_time = True

 

Sorry for not get back sooner, been busy trying to keep the server running


Edited by Johnny_Rico

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

i tried before, and now again and what you say is true, it doesn't like spaces in file names.

 

but still the weather and date is injected perfectly, only the time doesn't.

 

but thanks anyways for your input on the matter Maverick87Shaka :thumbup:

Ups,Sorry, I didn't get you had problem only on Mission time Injection, and after checking, I have the same issue! But for me it's not a big problem since I don't want my player found server on complete dark night!

 

I'm now testing the Real clock time injection on other machine :book:

 

EDIT:

open dcs_weather.py in notepad++

 

search for

b_change_time = False

change to

b_change_time = True

 

Sorry for not get back sooner, been busy trying to keep the server running

 

Ups again, obviously it's work for me on the testing machine.


Edited by Maverick87Shaka

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

open dcs_weather.py in notepad++

 

search for

b_change_time = False

change to

b_change_time = True

 

Sorry for not get back sooner, been busy trying to keep the server running

Hi Johnny,

regarding the TIME WorkAround to avoid night time on server,

I think there is a typo error on line 36

 

IF %HOUR% GEQ 18 TIME_CONTROL=6

 

should be:

IF %HOUR% GEQ 18 SET TIME_CONTROL=6

 

Maybe you can update the hosted package, it's also a problem shown on @Bottle-RUM logs

'TIME_CONTROL' is not recognized as an internal or external command

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

Hi Johnny,

regarding the TIME WorkAround to avoid night time on server,

I think there is a typo error on line 36

 

IF %HOUR% GEQ 18 TIME_CONTROL=6

should be:

IF %HOUR% GEQ 18 SET TIME_CONTROL=6

Maybe you can update the hosted package, it's also a problem shown on @Bottle-RUM logs

'TIME_CONTROL' is not recognized as an internal or external command

 

 

Good man finding that, the batch file is a cut down version of the one I use to manage our server, fixed it now

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

 

open dcs_weather.py in notepad++

 

search for

b_change_time = False

change to

b_change_time = True

 

Sorry for not get back sooner, been busy trying to keep the server running

 

Hi Johnny,

regarding the TIME WorkAround to avoid night time on server,

I think there is a typo error on line 36

 

IF %HOUR% GEQ 18 TIME_CONTROL=6

 

should be:

IF %HOUR% GEQ 18 SET TIME_CONTROL=6

 

Maybe you can update the hosted package, it's also a problem shown on @Bottle-RUM logs

'TIME_CONTROL' is not recognized as an internal or external command

 

 

i tried both of these but sadly still no real time is injected, the time is not really a big deal, i can use the the time given in cmd log to put it in the mission editor.

 

thanks for helping and your time Johnny_Rico & Maverick87Shaka

 

Intel® Core™ i7-6900K Processor (watercooled) - Asus ROG Rampage V Edition 10 (watercooled) motherbord - 8 x 8Gb Corsair Vengeance LPX DDR4-3333Mhz RAM (watercooled) - 2 x ROG-STRIX-GTX1080TI-11G-GAMING (watercooled)

- Creative X-Fi Titanium Fatal1ty Pro - Logitech G910 Orion Spark - Asus PG348 34'' LCD screen - Razor Tiamat 7.1 - Thrustmaster HOTAS Warthog Replica USAF A-10C - TrackIR 5 - Pro Flight Cessna Rudder Pedals - VAICOM 2.5 PRO

 

Link to comment
Share on other sites

  • 1 month later...
Is the download no longer available? I think I screwed mine up. I can't open missions in DCS after I've run this program on an existing mission in the folder. I probably just hosed something on my end and wanted to re-download just in case.

 

 

I'd say it's caused by one (?) of the recent updates; I didn't have this issue before, but now I also cannot open any mission edited with this mod. Shame because there's nothing like it for Normandy :cry:

Link to comment
Share on other sites

I got a message from Johnny_Rico (he's deep behind enemy lines and can't respond right now ;)).

 

Quote:

 

" Hi folks, the latest couple of patches have introduced a bug when saving out mission files.

The issue is to do with if the mission you are editing is older (been editing it for a while), it seems to strip out one of the lines used for controlling fog)

 

 

Brand new missions created in the editor appear to be un effected .... but unsure if it will stay the same going forward.

 

 

I am trying to work out how to fix this, will try to get it doe ASAP, as we rely upon this ourselves

 

 

Johnny

"

__________________

METAR weather for DCS World missions

 

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please PM me if you have any server feedback/issues

Link to comment
Share on other sites

Thanks Johnny for the update!

It's safe for me stay with the "old" version or I need to upgrade my script?

On the old version I did some customization to achive the injection of mission time with real time and night bias along all 24 hours of the server operation.

 

Thanks.

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

HERES JOHNNY!

 

 

 

you can use the new version it should be fine

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

HERES JOHNNY!

 

 

 

you can use the new version it should be fine

Welcome Back JOHNNY! I've updated to the new version and works fine :thumbup:

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

Thanks buddy it is good to be back tho at 90% warn I need to be careful

 

I will be doing some updates this week , to add new functionality for the new sand storm

weather parameters that DCS now has

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

I just started looking into this.

 

Got it working after some troubleshooting.

 

I have random time on, but always keep getting the dark hours of the day.

 

Found that this might help:

 

SET TEST=%time:~0,1%

SET HOUR=%time:~0,2%

IF "%TEST%" == " " SET HOUR=%time:~1,1%

 

 

: this override was added so that if it is too late in the year (dark a lot in evenings) then people would get some time were it is light for a bit

: IF %HOUR% GEQ 18 SET TIME_CONTROL=6

@echo %TIME_CONTROL%

 

But dont know when it will kick in.

I see that there is a table in dcs_weather in wich it got "template" times.

 

But it doesnt seem to use those?

[sIGPIC][/sIGPIC]

 

Vincere Est Totum

Link to comment
Share on other sites

: IF %HOUR% GEQ 18 SET TIME_CONTROL=6

change to

IF %HOUR% GEQ 18 SET TIME_CONTROL=6

 

it will pass 6 to the script and override real time and date and use preset number 6 instead when the real time on the PC is 18 or more

Click here for tutorials for using Virpil Hardware and Software

 

Click here for Virpil Flight equipment dimensions and pictures.

.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...