Example #1
0
	def __init__(self):
		catalog_url_head = "http://thredds.met.no/thredds/dodsC/"
		catalog_url_proj = "arcticdata/met.no/CLIPC"
		catalog_url      = catalog_url_head+catalog_url_proj+"/catalog.xml"

		wmsStart = 'http://thredds.met.no/thredds/wms/'#'https://climate4impact.eu/impactportal/ImpactService?source='
		#catalog = 'http://opendap.knmi.nl/knmi/thredds/catalog/'
		#opendap = 'http://opendap.knmi.nl/knmi/thredds/dodsC/'
		wmsEnd = '?service=WMS&version=1.3.0&request=GetCapabilities'



		ReadCatalog.__init__(self , catalog_url_head ,catalog_url_proj)


		layer = ''

		links , ncs = parse_c4i_catalog.readcatalog3B(catalog_url,catalog_url_head,wmsStart,wmsEnd , layer)

		self.print_list_to_file('met.no.wms',links)
		self.print_list_to_file('met.no.ncs',ncs)

		print len(ncs)

		#class UniDict():

		print ""

		uni = {}
		uni['variable'] = []
		uni['experiment'] = []
		uni['model'] = []
		uni['ensemble'] = []
		uni['regional'] = []
		#uni['8'] = []

		for n in ncs:
			line = n.split('_')
			#print line
			if line[1] not in uni['variable']:
				uni['variable'].append(line[1])
			elif line[3] not in uni['model']:
				uni['model'].append(line[3])	
			elif line[4] not in uni['experiment']:
				uni['experiment'].append(line[4])	
			elif line[5] not in uni['ensemble']:
				uni['ensemble'].append(line[5])
			elif line[6] not in uni['regional']:
				uni['regional'].append(line[6])	
			#elif line[8] not in uni['8']:
			#	uni['8'].append(line[8])

		for k in uni.keys():
			print k+": "+str(uni[k])

		print ""
		self.printSelf()
def createCSW2( template_xml, opendap , url, template_xmlNew, title , layer):
	
	ET.register_namespace("gmd" , "http://www.isotc211.org/2005/gmd")
	ET.register_namespace("gco" , "http://www.isotc211.org/2005/gco")
	ET.register_namespace("gmx" , "http://www.isotc211.org/2005/gmx")
	ET.register_namespace("gml" , "http://www.opengis.net/gml/3.2")
	ET.register_namespace("xlink","http://www.w3.org/1999/xlink")

	tree = ET.parse(template_xml)

	#print ET.dump(tree)
	WS_start = 'http://thredds.met.no/thredds/wms'#'https://climate4impact.eu/impactportal/ImpactService?source='
	#catalog = 'http://opendap.knmi.nl/knmi/thredds/catalog/'
	#opendap = 'http://opendap.knmi.nl/knmi/thredds/dodsC/'
	WS_end = '&service=WMS&request=GetCapabilities'
	#

	print template_xml
	print opendap
	print url
	print template_xmlNew
	print title

	#layer = "tasminAdjust"

	links , ncs = parse_c4i_catalog.readcatalog3B(url,opendap,WS_start,WS_end , layer)

	print_last_to_file("wms.last",links)
	print_last_to_file("ncs.last",ncs)

	( description\
		, keywords\
		, summary\
		, institution\
		, in_var_institution\
		, contact_email_1\
		, revision_date \
		, coverage_start \
		, coverage_end\
		, geospatial_lat_min\
		, geospatial_lat_max\
		, geospatial_lon_min\
		, geospatial_lon_max ) = read_ncfile.return_ncdump_variables(ncs)

	#print tree
	#print keywords
	#print in_var_institution
	
	generate_metadata_etree.replace_onlineResource(tree,ncs,links,layer,keywords)

	tree.write( template_xmlNew, method="xml")

	#print 'summary'
	#print str(summary)
	#print 'keywords'
	#print keywords

	# write metadata to file...
	generate_metadata_etree.replace_gmd_gco_gsl(template_xmlNew,
		title,
		str(description),
		keywords,
		summary[0], 
		institution[0], 
		str(in_var_institution),
		contact_email_1[0],
		revision_date,
		coverage_start,
		coverage_end, 
		geospatial_lat_min, 
		geospatial_lat_max, 
		geospatial_lon_min, 
		geospatial_lon_max)